Skip to content

Instantly share code, notes, and snippets.

@radcliff
radcliff / filterable.rb
Created July 31, 2017 05:05 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@radcliff
radcliff / index.js
Created March 14, 2017 18:26
Rumbda basics (tl;dr)
const exec = require('child_process').exec;
exports.handler = function(event, context, callback) {
const child = exec('./ruby_wrapper ' + "'" + JSON.stringify(event) + "'", (error, stdout, stderr) => {
callback(null, JSON.parse(stdout));
});
child.stdout.on('data', console.log);
child.stderr.on('data', console.error);
};
@radcliff
radcliff / base58.rb
Created March 5, 2016 07:32 — forked from jou/base58.rb
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
# 14 rue de Plaisance, 75014 Paris, France
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@radcliff
radcliff / quicksort.js
Created February 9, 2016 21:56
Javascript implementation of quicksort
/*
Quicksort!
Name your function quickSort.
Quicksort should grab a pivot from the end and then separate the list (not including the pivot)
into two lists, smaller than the pivot and larger than the pivot. Call quickSort on both of those
lists independently. Once those two lists come back sorted, concatenate the "left" (or smaller numbers)
list, the pivot, and the "right" (or larger numbers) list and return that. The base case is when quickSort
@radcliff
radcliff / getstationdata.json
Created January 29, 2016 22:36
Netatmo GETSTATIONSDATA Response
{
"body": {
"devices": [
{
"_id": "70:ee:50:00:00:14",
"co2_calibrating": false,
"firmware": 91,
"last_status_store": 1441872001,
"last_upgrade": 1440507643,
"module_name": "ind",
@radcliff
radcliff / API.md
Created January 23, 2016 20:50 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@radcliff
radcliff / README.md
Created January 13, 2016 14:53 — forked from mcallaghan/README.md
Country Codes

#Country Codes This uses the CIA World Factbook compendium of country codes to convert one type of code to another easily and programmatically. The table on this website was converted into JSON format on 20/11/2014.

As an example, enter the input code type, a code, and the output code type (separated by commas) above. Choose between the following options (Case sensitive)

- name
- GEC
- ISO_ALPHA_2
- ISO_ALPHA_3
@radcliff
radcliff / 2to3LetterCountryData
Created January 13, 2016 14:51 — forked from 5herah/2to3LetterCountryData
Countries! ISO Alpha-2 Codes with their ISO Alpha-3 Code counterparts
{
"AF":"AFG",
"AX":"ALA",
"AL":"ALB",
"DZ":"DZA",
"AS":"ASM",
"AD":"AND",
"AO":"AGO",
"AI":"AIA",
"AQ":"ATA",
@radcliff
radcliff / array.js
Created November 8, 2015 17:46 — forked from NuckChorris/array.js
In Ember-CLI, transforms are located in app/transforms/name.js
// app/transforms/array.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(value) {
if (Ember.isArray(value)) {
return Ember.A(value);
} else {
return Ember.A();
@radcliff
radcliff / 0_reuse_code.js
Last active September 17, 2015 21:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console