Skip to content

Instantly share code, notes, and snippets.

View rabidaudio's full-sized avatar

Julien (CJK) rabidaudio

View GitHub Profile
@rabidaudio
rabidaudio / csvparse.rb
Created January 13, 2016 17:57
CSV rows to objects
reqire 'csv'
csv = CSV.parse(File.read('input.csv'))
headers = csv.shift
objects = csv.map { |row| Hash[headers.zip(row)] }
@rabidaudio
rabidaudio / json2csv.rb
Created December 18, 2015 22:10
Convert JSON file to CSV
require 'csv'
require 'json'
# parse some json into hash array
data = JSON.parse(File.read("in.json"))
# get all headers appearing anywhere in data
keys = []
data.each do |hash|
keys = keys.concat(hash.keys).uniq
@rabidaudio
rabidaudio / gist:5d8dad6b020928b71f92
Last active December 10, 2015 22:27
Connecting to bluetooth serial tty
# get mac addresses for nearby devices
hcitool scan
# bind to a device
rfcomm bind 0 00:0D:18:00:00:01
# open tty
minicom -D /dev/rfcomm0
# press Ctrl-A Z A to turn line breaks on
# close when done:
rfcomm release /dev/rfcomm0
@rabidaudio
rabidaudio / HyperlinkTextView.java
Created September 25, 2015 21:53
HyperlinkTextView.java
package audio.rabid.dev.utils;
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.text.style.ClickableSpan;
import android.util.AttributeSet;
import android.view.View;
@rabidaudio
rabidaudio / EasyArrayAdapter.java
Last active December 29, 2015 01:54
A helper class for Android ArrayAdapters
package audio.rabid.dev.utils;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import java.util.ArrayList;
@rabidaudio
rabidaudio / jquery.dragHighlight.js
Last active October 27, 2016 22:56
A little jQuery plugin for draggable selections, a la whenisgood.net
/**
* A simple little jQuery plugin for doing draggable selections (like http://whenisgood.net/).
* Maybe not super performant, but it's jQuery so you already don't care.
*
* Demo:
* http://jsfiddle.net/qa06oab2/
*
* Usage:
* $(<selector for elements>).dragHighlight(<optional name of class to add, defaults to 'selected'>);
*
@rabidaudio
rabidaudio / LabelButton.js
Created March 12, 2015 08:09
MonkeyPatch Phaser game engine with a label button
//source: http://www.html5gamedevs.com/topic/2847-button-text/
var LabelButton = function(game, x, y, key, label, style, callback,
callbackContext, overFrame, outFrame, downFrame, upFrame)
{
Phaser.Button.call(this, game, x, y, key, callback,
callbackContext, overFrame, outFrame, downFrame, upFrame);
//Style how you wish...
@rabidaudio
rabidaudio / gist:fa6849e4c1c91309e789
Created March 2, 2015 19:20
HTML alignment center lines
<div style="position: fixed; width:1px; left: 50%; top:0; bottom: 0; background-color: black;"></div>
<div style="position: fixed; height:1px; left: 0; top:50%; right: 0; background-color: black;"></div>
@rabidaudio
rabidaudio / gist:fa8efc798b3564fd5a75
Created February 22, 2015 00:09
Follow a page of people on twitter
$(".user-actions-follow-button").each(function(){ if($(this).css("background-color")==="rgb(245, 248, 250)") $(this).click() });