Thursday, November 9, 2017

verify JSON files in the shell (npm, bash)

I do most of my mass text-processing in Perl. It's been a wake-up that Perl's JSON libraries & tools are a little eccentric (perhaps that shouldn't be surprising) or 'minimal', rather than warm & fuzzy: that would be the best word.

Anyway. Let's verify a bunch of json files in the shell. This follows a lengthy period of combining &  de-duplicating two (pretty crap & overlapping) datasets into a single json format. 

Install jsonlint from via npm: https://www.npmjs.com/package/jsonlint

This gives you a decent executable json linter which may or may not be the same codebase as the ever-awesome http://jsonlint.com/

and call it from the shell:

for f in *.json 
do 
 echo "Processing $f" 
 jsonlint -cq $f 
done

the q flag prevents json printing to the shell & only shows errors

Sunday, October 13, 2013

console colours on RedHat linux

or, how to turn them off. You need sudo or root:

chmod 000 /etc/profile.d/colorls.*

That's a global disable but honestly, dark blue text on black? It's been bugging me for years. RedHat-derived Linux has been shipping with the ls command aliased to /bin/ls --color=auto for an extremely long time though I don't remember anyone asking me about it.

Alternatively, if you want to customise this kind of thing, this article might be a good starting point.


Saturday, October 12, 2013

Web Design: Responsive Image Sizes

Put this in your CSS:

img {
     max-width: 100%;
     height: auto;
}

- making sure it doesn't get overridden at some point in your more specific CSS classes.

This is a prime technique for sites that have some big feature image, usually on the front page that needs to be there when someone looks at it using a smart phone etc. The image will scale on nearly everything except IE8 - for which webdesignerwall offers a specific solution.

Friday, October 4, 2013

a development process for Max MSP or Max for Live

back on the Max jag again - I am building & re-building a small set of patchers to help me create music/soundtracks for some performance works I've been asked to help out with.

One of these - basically a sample-player which uses soundfile markers to determine playback - has been around since 2006 in various forms. I even wrote a helper app for it using Libsndfile, before Patrick Delges' sfmarkers-v0-4-1 object was around (or before I became aware of it's existence).

I think I just rewrote it for the seventh time - it's definately acting in a more consistent manner now. AIFF only - there just seem to be endless uncommon & weird problems getting markers out of WAV files. I also created an M4L version, which was instructive in the problems that embedding in an Ableton project solves (memorising specific setting per-instance of the patch) - and also the extra problems it brings up (access to presets & automation).

The need to move this patch/instrument between a few different Macs sent me off to finally look at version control for Max.

more on this in a minute...

Tuesday, August 20, 2013

Arduino: Motion sensor, making it work

I had some problems getting this PIR motion sensor, which I'm pretty sure is the same as this working well, connected to either an Arduino Duemillanove or a Teensy 2.0 micro. It seemed to trigger randomly or not at all. Based on a clue from the Sparkfun comments on the item: provide the sensor with it's own or extra power as the micro board might not be providing enough volts to drive it properly.

This approach seems to provide the answer: power the PIR sensor with the positive side of a 9v battery, (disconnecting it from the micro board's power), whilst leaving the rest of the circuit (like this) in place.

In hindsight, I'm assuming the problem I had stemmed from the Arduino itself using up all the juice available from the USB connection to the computer. Powering the board from a DC adapter with current to spare would help too.

With a movement/presence detector like this, adding a big LED or a buzzer to your circuit and sketch, indicating when the sensor detects movement will help a lot when testing.


dual-powered: the PIR sensor connected to a Teensy. 9V battery for the sensor, an old phone charger provides +5v via the Teensy's mini USB connector.

Saturday, August 17, 2013

Arduino: Configuring on Linux

You want to install the Arduino development environment on a linux machine: there is the standard download and there are distro-specific installers available. There are also some instruction on setting up your environment linked from the official pages.

The route I followed on my usual distro (Centos 6) was to install Java, then the Arduino download. There were still a couple of non-functioning parts: errors from the rxtx library about lockfiles and greyed out serial port menu in the Arduino IDE.

These are RedHat/Fedora/Centos permissions issues that can be resolved easily:

* edit /etc/group

* add your username to the uucp, lock and dialout groups

That should fix it by giving your user the required access to the computer's lock directory and serial ports 

Wednesday, June 26, 2013

RFID tag collision

What happens if you try to identify 'something' by pinpointing it with an RFID tag - but in too-close proximity to another tag? By the look of things - unpredictability:

http://www.technovelgy.com/ct/Technology-Article.asp?ArtNum=57