Skip to content

Instantly share code, notes, and snippets.

@johncant
johncant / Makefile.am
Created January 10, 2014 16:15
Use GNU autotools to call node-gyp to build a native node module
bin_PROGRAMS = some_node_module
some_node_module$(EXEEXT):
-cd $(NODE_MODULE_DIR) && node-gyp build
clean-local:
-cd $(NODE_MODULE_DIR) && node-gyp clean
@johncant
johncant / attributify.rb
Created July 22, 2013 17:58
This simple controller mixin allows you to lose the "_attributes" suffix when POST/PUTting data to your API, while maintaining the same nested attribute model behaviour. Simply replace params[:posts] with attributify(:posts) in your controllers. The old behaviour should still work.
module Attributify
def attributify(key, unprocessed=params[key])
if unprocessed.is_a? Hash
specific_params = {}
unprocessed.each do |k,v|
if (v.is_a?(Hash) && !k.to_s.match(/_attributes$/)) or (v.is_a?(Array) && !k.to_s.match(/_ids$/))
# Nested, so suffix with '_attributes'
specific_params["#{k}_attributes".to_sym] = attributify(key, v)
@johncant
johncant / Broken Holoviews example 2.ipynb
Last active October 31, 2018 23:05
Broken Holoviews example 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johncant
johncant / Broken Holoviews Example 1.ipynb
Created October 29, 2018 23:15
Holoviews rename issue
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johncant
johncant / Holoviews timezone example.ipynb
Created October 27, 2018 17:46
Holoviews timezone example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johncant
johncant / Holoviews timezone example.ipynb
Created October 27, 2018 17:44
Holoviews timezone example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johncant
johncant / Broken holoviews example.ipynb
Last active September 23, 2018 16:43
Broken holoviews example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johncant
johncant / write_sd_image
Created March 21, 2015 18:15
Use rooted Android phone to write Raspberry Pi image to microSSD card
#!/bin/bash
# Use a rooted android phone to load a raspberry pi image onto a microSSD card.
#
# adb push /dev/block/$PHONEBLOCKDEVICE
# won't work because you are not root by default
#
# Commands like
# cat $IMAGEFILE | adb su -c dd of=/dev/block/$PHONEBLOCKDEVICE
# won't work because adb corrupts the stream
#
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*******************************************************
* USB-ISS test application for Linux. *
* *
* Sets USB-ISS into spi mode and reads and writes from *
* microchips 23k256 *
* *
* Compiled using gcc, tested on Ubunto 10.4 LTS. *
* *
* By James Henderson, 2012. *
*******************************************************/