Skip to content

Instantly share code, notes, and snippets.

View idkjs's full-sized avatar

Alain Armand idkjs

View GitHub Profile
@quellish
quellish / coredatajsonremap.m
Created September 21, 2014 08:50
Remapping JSON keys to Core Data attributes using the userInfo dictionary of the attribute entity description as defined in the Core Data Model Editor
entityUserInfo = [entity userInfo];
reKeyedValues = [[NSMutableDictionary alloc] initWithDictionary:jsonObject];
for (NSString *key in keyedValues){
if ([entityUserInfo valueForKey:key] != nil){
[reKeyedValues setValue:[keyedValues valueForKey:key] forKey:[entityUserInfo valueForKey:key]];
// Remove the original key
[reKeyedValues setValue:nil forKey:key];
}
}
@tjulien
tjulien / geohaystack example
Created January 28, 2011 18:53
geohaystack example
https://github.com/mongodb/mongo/blob/master/jstests/geo_haystack2.js
t = db.geo_haystack2
t.drop()
function distance( a , b ){
var x = a[0] - b[0];
var y = a[1] - b[1];
return Math.sqrt( ( x * x ) + ( y * y ) );
}
@pierre-b
pierre-b / gcloud-fish.sh
Last active March 1, 2017 17:21
Set fish shell for gcloud sdk on OSX
set fish_user_paths path_to_your_google_cloud_sdk/bin
set -x MANPATH path_to_your_google_cloud_sdk/help/man /usr/local/share/man /usr/share/man /opt/x11/share/man
@idkjs
idkjs / gcloud-fish.sh
Created March 1, 2017 17:21 — forked from pierre-b/gcloud-fish.sh
Set fish shell for gcloud sdk on OSX
set fish_user_paths path_to_your_google_cloud_sdk/bin
set -x MANPATH path_to_your_google_cloud_sdk/help/man /usr/local/share/man /usr/share/man /opt/x11/share/man
@geocine
geocine / graphiql.html
Created November 3, 2016 15:07
stand alone graphiql
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="graphql,graphiql" />
<title>GraphiQL</title>
import React from 'react';
import { compose, withHandlers } from 'recompose';
import { injectIntl } from 'react-intl';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
type MutationButtonType = {
toggleMutation: Function,
label: React.Element<any>,
};
plutil -p xml1 Info.plist | grep "BundleName" | sed 's/ "\(.*\)" => "\(.*\)"/\2/'
plutil -p xml1 Info.plist | grep "BundleShortVersionString" | sed 's/ "\(.*\)" => "\(.*\)"/\2/'
plutil -p xml1 Info.plist | grep "BundleDisplayName" | sed 's/ "\(.*\)" => "\(.*\)"/\2/'
plutil -p xml1 Info.plist | grep "BundleIdentifier" | sed 's/ "\(.*\)" => "\(.*\)"/\2/'
@MikeBild
MikeBild / compose-graphql-queries.js
Last active September 12, 2017 20:28
API Prototype - compose React components to Higher-Order-Components with GraphQL Fragment / Query composer
export const Gists = props =>
<div>
{
props.viewer.gists &&
props.viewer.gists.map(x => <p>{x.description}</p>)
}
</div>
export const GistsWithGraphQL = compose(
withGraphQL(variables => Fragment`fragment gists on Gist {

agnostic modules

Most of the modules I write are "agnostic" in that they should work in Node, browserify, webpack, Rollup, jspm... hell, even Unreal.js. It's just ES5, CommonJS and a few quirks like process.nextTick or require('path') (which browserify and webpack will shim).

Other modules are a bit trickier, and need to include a static asset like HTML, GLSL or another file.

In Node you might see this:

var fs = require('fs')
@katowulf
katowulf / jwtparser.js
Last active September 19, 2017 13:11
Deconstruct a JWT token for Firebase
// Helper function to extract claims from a JWT. Does *not* verify the
// validity of the token.
// credits: https://github.com/firebase/angularFire/blob/master/angularFire.js#L370
// polyfill window.atob() for IE8: https://github.com/davidchambers/Base64.js
// or really fast Base64 by Fred Palmer: https://code.google.com/p/javascriptbase64/
function deconstructJWT(token) {
var segments = token.split(".");
if (!segments instanceof Array || segments.length !== 3) {
throw new Error("Invalid JWT");
}