Skip to content

Instantly share code, notes, and snippets.

View ChrisCinelli's full-sized avatar

Chris Cinelli ChrisCinelli

  • Close5
  • San Francisco, CA, United States
View GitHub Profile
@ChrisCinelli
ChrisCinelli / find-in-json.js
Created April 7, 2017 00:14 — forked from iwek/find-in-json.js
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@ChrisCinelli
ChrisCinelli / exportjson.js
Last active December 2, 2015 08:29 — forked from pamelafox/exportjson.js
Google Spreadsheet return JSON from a table. Ex: tableToJSON(A1:C3)
function tableToJSON(ar, transpose){
if (transpose) ar = arrayTranspose_(ar);
var headers = ar.shift();
return JSON.stringify(getObjects(ar, normalizeHeaders(headers)));
}
// For every row of data in data, generates an object that contains the data. Names of
// object fields are defined in keys.
// Arguments:
// - data: JavaScript 2d array
@ChrisCinelli
ChrisCinelli / gist:e8339b39239ac9713655
Created December 2, 2015 05:32 — forked from mhawksey/gist:1442370
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
# -*- coding: utf-8 -*-
"""
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html
Author: Ola Sitarska <ola@sitarska.com>
Copyright: Licensed under the GPL-3 (http://www.gnu.org/licenses/gpl-3.0.html)
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/
"""
@ChrisCinelli
ChrisCinelli / Gemfile
Created April 30, 2013 22:17 — forked from sr/Gemfile
source "http://rubygems.org"
gem "janky", "~>0.9"
gem "pg"
gem "thin"
/*
* Remote authentication snippet in PHP fro Zendesk
* See: http://www.zendesk.com/support/api/remote-authentication
*/
/* This is the token that you can find or recreate on https://bloomboard.zendesk.com/agent/#/admin/security */
$token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
/* Insert your account prefix here. Ex: yoursite.zendesk.com */
$urlPrefix = "yoursite";
@ChrisCinelli
ChrisCinelli / copy-s3-bucket.rb
Created November 3, 2012 19:56 — forked from zefer/copy-s3-bucket.rb
Copy contents of an S3 bucket to a another bucket using an EC2 instance and a simple Ruby script. Useful for transferring large amounts of data and will work across geographic regions.
require 'rubygems'
require 'right_aws'
aws_access_key_id = 'your-access-key'
aws_secret_access_key = 'your-secret-key'
target_bucket = 'your-source-bucket'
destination_bucket = 'your-destination-bucket'
s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key)