Skip to content

Instantly share code, notes, and snippets.

View yocontra's full-sized avatar

contra yocontra

View GitHub Profile
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var styl = require('gulp-styl');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var paths = {
js: 'src/**/*.js',
@yocontra
yocontra / stuff.sh
Created December 30, 2013 01:27
"im one prototyping" command to solidify version dependencies. must have underscore-cli installed globally first
cat package.json | underscore extract devDependencies | underscore keys --outfmt=text | xargs npm install --save-dev
cat package.json | underscore extract dependencies | underscore keys --outfmt=text | xargs npm install --save
@yocontra
yocontra / watchem.js
Created December 29, 2013 23:06
glob watching sandbox
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var less = require('gulp-less');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var outDir = './temp';
var sources = {
scripts: './app/scripts/**/*.js',
@yocontra
yocontra / gulpfile.js
Last active January 1, 2016 00:29
gulpfile for a simple livereload static web server. this is a proof of concept that uses no plugins to do the work. obviously there are plugins that eliminate almost all of this code but i thought it would be a fun demonstration. this will trigger livereload any time any file is modified in the current working directory. it also serves the curre…
var gulp = require('gulp');
var gutil = require('gulp-util');
var express = require('express');
var path = require('path');
var tinylr = require('tiny-lr');
var createServers = function(port, lrport) {
var lr = tinylr();
lr.listen(lrport, function() {
gutil.log('LR Listening on', lrport);
@yocontra
yocontra / clusterfuck.java
Created September 24, 2013 22:37
pre-conversion
public static String byteArrayToHex(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
byte[] arrayOfByte = new byte[paramInt2];
for (int i = 0; ; i++)
{
if (i >= paramInt2)
return ByteUtility.bytesToHex(arrayOfByte);
arrayOfByte[i] = paramArrayOfByte[(i + paramInt1)];
}
}
@yocontra
yocontra / CommandEncoder.java
Created September 23, 2013 22:50
Command Encoder for Brookstone Rover 2.0 TCP Protocol
package com.wificar.component;
import android.util.Log;
import com.wificar.WificarActivity;
import com.wificar.util.BlowFish;
import com.wificar.util.ByteUtility;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.http.util.ByteArrayBuffer;
@yocontra
yocontra / log.js
Last active December 22, 2015 02:19
Logging utility function for async.js
var log = function(msg) {
return function() {
var args = Array.prototype.slice.call(arguments);
var cb = args.pop();
console.log(msg);
cb.apply(null, [null].concat(args));
};
};
@yocontra
yocontra / import-sql.js
Created August 29, 2013 00:41
Dumps stuff into MySQL
var child_process = require('child_process');
var ConnectionConfig = require('mysql/lib/ConnectionConfig');
// first argument = mysql://whatever.com/whatevs
// second argument = string of sql file
module.exports = function(url, sqlData, cb) {
var opt = ConnectionConfig.parseUrl(url);
var args = [];
if (opt.user) args.push("--user="+opt.user);
@yocontra
yocontra / polyfill.js
Created August 28, 2013 17:04 — forked from remy/gist:350433
LocalStorage/SessionStorage polyfill
var isStorageAvailable = function (storage) {
if (typeof storage == 'undefined') return false;
try { // hack for safari incognito
storage.setItem("storage", "");
storage.getItem("storage");
storage.removeItem("storage");
return true;
}
catch (err) {
return false;
@yocontra
yocontra / rick-roll.js
Created August 13, 2013 07:34
Demo for nodecast
var nodecast = require('nodecast');
var stream = nodecast.find();
stream.on('device', function(device) {
console.log('Found device', device.name);
var youtube = device.app('YouTube');
// you can change this video to anything you want
youtube.start('v=oHg5SJYRHA0', function(err) {