Skip to content

Instantly share code, notes, and snippets.

View subclass.js
subClass = function (source, prototype) {
var dummy = new source.constructor;
for (var key in prototype) {
dummy[key] = prototype[key];
}
source.__proto__ = dummy;
}
@phaistonian
phaistonian / d3_min_altered
Created May 8, 2013
A d3_min variation. Use native Math.min method if applicable for faster results.
View d3_min_altered
d3.min = function(array, f) {
var i = -1, n = array.length, a, b;
if (!f) {
for (var y = 0; parseInt(array[y]); y++) {}
if (y === array.length) return Math.min.apply(Math, array);
}
// Continue existing logic below
View gist:5542793
[ '20', '3', '30', '10' ].sort(function (a, b) {
return a == b ? 0 : (a < b ? -1 : 1);
})[0];
[ 20, 3, 30, 10 ].sort(function (a, b) {
return a == b ? 0 : (a < b ? -1 : 1);
})[0];
View Sublime Text preferences
{
"bold_folder_labels": true,
"build_on_save": 0,
"color_scheme": "Packages/User/Tomorrow-Night.tmTheme",
"close_windows_when_empty": true,
"draw_indent_guides": true,
"caret_style": "phase",
"fallback_encoding": "Greek (ISO 8859-7)",
"folder_exclude_patterns":
[
@phaistonian
phaistonian / Select Similar.sketchplugin
Last active Aug 29, 2015
Sketch: Select similar layers or groups based on a number of properties (and guesses)
View Select Similar.sketchplugin
// Select Similar (ctrl shift a)
// https://gist.githubusercontent.com/phaistonian/b3737cf05c1b6a61dbb7/raw/1f1ca90f1c72e395cb4d2abfc23315c47dc5c25d/Select%20Similar.sketchplugin
/* Based on initial work by Ale Muñoz */
(function(){
var sel = selection[0], all_layers = [[doc currentPage] children];
if (sel) {
var query = getIdForElement(sel), type = [sel className], found = 0;
View gist:54ad523019ace6e7b6cb
var hash = {};
[1,2,3,3,5,1].filter(function (item) { if (hash[item]) return true; hash[item] = false; return true; });
@phaistonian
phaistonian / .eslintrc
Last active Apr 11, 2016
To be used in projects, Sublime Text, VIM etc.
View .eslintrc
{
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"classes": true,
"generators": true,
"experimentalObjectRestSpread": true
},
View (my) Sublime Text 3 options
{
"bold_folder_labels": true,
"build_on_save": false,
"caret_style": "phase",
"close_windows_when_empty": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"default": "Default.sublime-theme",
"detect_indentation": false,
"draw_indent_guides": true,
"draw_minimap_border": true,
@phaistonian
phaistonian / firesync.js
Last active Nov 10, 2015
A Redux middleware to broadcast state (actions + data) using Firebase (http://d.pr/v/13oMK)
View firesync.js
import Rebase from 're-base';
const endPoint = 'actions';
const firebaseUrl = 'https://firesync.firebaseio.com';
const client = String(Date.now() + Math.random() * 100);
const data = [];
let initiated = false;
const base = Rebase.createClass(firebaseUrl);
function firesync (store) {
View .gitignore
# Misc related to npm and webpack
node_modules
build
dist
webpack-stats.json
npm-debug.log
# Sublime related - just in case
###################
sublime-*