Skip to content

Instantly share code, notes, and snippets.

View sbrichardson's full-sized avatar
:octocat:
In coding land

Stephen Richardson sbrichardson

:octocat:
In coding land
View GitHub Profile
// A Meteor CheatSheet for Iron-Router by Gentlenode.com (converted to JavaScript using http://js2.coffee)
// Original Gist: https://gist.github.com/LeCoupa/59738c28fdc9085b9212
var AdminController, PostsEditController;
meteor add iron: router
meteor update iron: router
// Iron Router > Configuration
@fractastical
fractastical / client.js
Created June 3, 2012 15:21 — forked from matteoagosti/client.js
Twitter OAUTH using Meteorjs
var ClientRouter = Backbone.Router.extend({
routes: {
'404': 'notfound',
'500': 'error',
'auth': 'auth',
'authCallback?oauth_token=:oauth_token&oauth_verifier=:oauth_verifier': 'authCallback',
'': 'defaultRoute'
},
defaultRoute: function() {
@paulcpk
paulcpk / cleanTypenameFieldLink.ts
Last active June 19, 2018 04:12
This is a custom ApolloLink which we use to clean the "__typename" field to prevent sending it to the GraphQL server. omitDeep based on this gist: https://gist.github.com/Billy-/d94b65998501736bfe6521eadc1ab538
type BatchLoadFn<K, V> = (keys: Array<K>) => Promise<Array<V | Error>>;
type LoadAllFn<K, V> = () => Promise<Array<[K, V]>>;
type Options<K, V> = {
batch?: boolean,
cache?: boolean,
cacheMap?: CacheMap<K, Promise<V>>,
cacheKeyFn?: (key: any) => any
};
@tresf
tresf / zpl.js
Last active January 7, 2019 23:23
ZPL Label Sample
/*
* The re-use of the ZPL syntax and US Shipping Label
* - Provided as education example
* - Re-released by open source community under fair use
* - Fair use per US Copyright Act of 1976, 17 U.S.C. § 107
* The ZPL Printer Language
* - Copyright © 2014 ZIH Corp (zebra.com)
* The JavaScript syntax (minus ZPL markdown)
* Copyright © 2015 QZ Industries, LLC (qz.io)
* Licence: LGPL 2.1
@sbrichardson
sbrichardson / opencv_blackfly.cpp
Created June 18, 2019 05:08 — forked from kevinhughes27/opencv_blackfly.cpp
A simple program showing how to capture from a Point Grey Research Camera and display the image using OpenCV
#include "FlyCapture2.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace FlyCapture2;
int main()
@markerikson
markerikson / react-redux-perf.md
Last active July 14, 2020 16:57
React/Redux perf discussion

[10:57 PM] acemarke: so, the canonical "bad perf for React+Redux" example is a todo list of 10,000 items
[10:58 PM] Sinistral: I always thought passing an object through was just a typical JS pointer
[10:58 PM] acemarke: the trivially obvious store shape is a single array of all 10K todo objects
[10:58 PM] acemarke: with a single connected list component
[10:58 PM] Sinistral: eh, ignore me, finish
[10:59 PM] acemarke: the list's mapState retrieves the array, and the list component renders this.props.todos.map(todo => <TodoListItem todo={todo} /> )
[10:59 PM] acemarke: which works fine the first time around
[10:59 PM] acemarke: but if you edit, say, the "text" field in a single todo
[11:00 PM] acemarke: your reducer returns a new updated todo object inside of a new array reference, shallow-copied
[11:00 PM] Sinistral: You are re-drawing the enti...oh

@songouyang
songouyang / font.sh
Created August 18, 2018 12:52
iterm2安装 SF Mono 字体
cd /Applications/Utilities/Terminal.app/Contents/Resources/Fonts/
cp *.otf ~/Library/Fonts/
@mfellner
mfellner / graphql.ts
Created July 8, 2019 20:42
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@fernandomora
fernandomora / fswatch-rsync
Created September 12, 2016 22:43
Watch folder with fswatch and sync it with rsync
#!/usr/bin/env bash
# check color support
colors=$(tput colors)
if (($colors >= 8)); then
red='\033[0;31m'
nocolor='\033[00m'
else
red=
nocolor=