Skip to content

Instantly share code, notes, and snippets.

View CrocoDillon's full-sized avatar

Dillon de Voor CrocoDillon

View GitHub Profile
@cowboy
cowboy / ba-objecttotype.js
Created August 8, 2011 15:22
Object.toType
// See http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
(function(global) {
// Maintain a map of already-encountered types for super-fast lookups. This
// serves the dual purpose of being an object from which to use the function
// Object.prototype.toString for retrieving an object's [[Class]].
var types = {};
// Return a useful value based on a passed object's [[Class]] (when possible).
Object.toType = function(obj) {
@kopiro
kopiro / sudoku-solver-with-bt.js
Created May 11, 2015 20:45
Sudoku solver with backtracking
function getp(puzzle, x, y) {
var hash = {};
for (var u = 0; u < 9; u++) hash[ puzzle[y][u] ] = 1;
for (var u = 0; u < 9; u++) hash[ puzzle[u][x] ] = 1;
for (var u = 0; u < 9; u++) hash[ puzzle[ 3*((y/3)|0) + ((u/3)|0) ][ 3*((x/3)|0) + (u%3) ] ] = 1;
var poss = [];
for (var i = 1; i <= 9; i++) if (!(i in hash)) poss.push(i);
return poss;
}
@bubbleheadinc
bubbleheadinc / gist:5725438
Created June 6, 2013 22:15
Mixin loop to spit out span classes based on # of grid columns for JustifyGrid.com SCSS
@mixin grid-spans($col-span){
@while $col-span > 0{
.grid-span-#{$col-span}{
width: grid-span($col-span);
}
$col-span: $col-span - 1;
}
}
if (typeof Promise === 'undefined') {
require.ensure([], (require) => {
require('imports?this=>window!es6-promise')
})
}
if (typeof fetch === 'undefined') {
require.ensure([], (require) => {
require('imports?self=>window!whatwg-fetch')
})
@cahnory
cahnory / middleware.js
Created December 21, 2015 15:55
koa-webpack-middleware
import connect from 'koa-connect';
import compose from 'koa-compose';
import webpack from 'webpack';
import webpackDev from 'webpack-dev-middleware';
import webpackHot from 'webpack-hot-middleware';
export default function (config = {}) {
let compiler = webpack(config);
return compose([
<?php
// you can't just get this as JSON in the first place, can you ...?
$xml = simplexml_load_file( "http://readability.com/christopherburton/latest/feed" );
$json = json_encode( $xml );
$array = json_decode( $json,TRUE );
$items = $array['channel']['item'];
// we're doing this now so we can sanitize the data without requiring a second loop
// (substitute your actual DB credentials)
$DB = new mysqli( DB_HOST,DB_USER,DB_PASS,DB_NAME );
@shussekaido
shussekaido / our_setup_script.js
Created December 5, 2012 14:56
MongoDB M102 week6 file
db = db.getSisterDB("config");
var mongosConn = db; // assume we connected to a mongos to get going
var res = null;
function check() {
printjson(res);
if( !res || !res.ok ) {
throw "check(): not ok, stopping";
@corydorning
corydorning / Cross-Browser ::before and ::after pseudo-class polyfill
Last active February 18, 2022 00:24
Cross-Browser ::before and ::after pseudo-class polyfill
/* =============================================================================
CSS Declarations
========================================================================== */
/* ==|== The Standard Way =================================================== */
.foo::before {
/* ...css rules... */
}
@razwan
razwan / _baseline.scss
Created April 14, 2014 16:20
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@malarkey
malarkey / Three Wise Monkeys.md
Created December 2, 2012 14:26
Three Wise Monkeys (NDA)

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?