Skip to content

Instantly share code, notes, and snippets.

@brandonpapworth
brandonpapworth / gist:5537102
Created May 7, 2013 23:43
Adapted from http://mattstow.com/responsive-design-in-ie10-on-windows-phone-8.html , This will append a style tag to the document head containing the @Viewport rule necessary for windows * 8 systems to properly read. Since Windows Phone 8 doesn't react as it should to width=device-width rules, it's necessary to have it defined with a width of 'a…
<script>
/*
* IE10 viewport handler for use on mobile devices and snapped desktop
*/
(function(document,navigator) {
'use strict';
var msViewportStyleShim = document.createElement('style');
msViewportStyleShim.appendChild(
document.createTextNode(
'@-ms-viewport{width:' + (
@brandonpapworth
brandonpapworth / gist:5975955
Created July 11, 2013 14:29
Just an example of simulating touch events using the CustomEvent api. Sloppily used jQuery, but this can be easily switched to use addEventListener.
if (!('ontouchstart' in window)) {
// create synthetic touch events
var idCounter = 0,
emptyArray = [];
$(document).on('mousedown',function (e) {
console.log('faking touchstart');
var evt = new CustomEvent('touchstart',{
bubbles : true,
cancelable : true
});
util = require "util"
xmpp = require "node-xmpp"
oscar = require 'oscar'
express = require "express"
###
The XMPP bot.
###
var express = require('express'),
request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys');
var app = express.createServer(
express.logger(),
express.bodyDecoder()
);
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
#server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;
@brandonpapworth
brandonpapworth / gist:8952971
Created February 12, 2014 10:20
Iron-clad console logging alternative. Use like " logger('log', /* all your arguments you'd normally pass */); "
/**
* shims in console support and ignores calls if console
* object is not present in window
* @param {String} kind the kind of logging statement to make
* @param {Any} argX (optional) the remainder of the logging arguments
* @return {Object} returns App
*/
function logger (kind /*[,arg1, arg2, ..., argN]*/) {
try {
if (typeof kind === 'string' && window.console && typeof window.console[kind] === 'function' && typeof Array.prototype.slice === 'function') {
@brandonpapworth
brandonpapworth / jsmetainclude.html
Created February 20, 2014 23:57
meta tag based javascript include definition
<!DOCTYPE html>
<html>
<head>
<title><!-- whatever -->A Title</title>
<meta charset="utf-8">
<!-- [START] script define start -->
<meta name="jsinject-modernizer" content="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.1/modernizr.min.js">
<meta name="jsinject-jquery" content="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js">
<!-- [END] script define -->
#!/bin/sh
# Dropbox setup on a headless Ubuntu Server
# Script written by Jesse B. Hannah (http://jbhannah.net) <jesse@jbhannah.net>
# Based on http://wiki.dropbox.com/TipsAndTricks/UbuntuServerInstall
###
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
'use strict';
const path = require('path');
const del = require('del');
const gulp = require('gulp');
const watch = require('gulp-watch');
const FILE_SRC_GLOB = ['src/**/*'];
const FILE_SRC_GLOB_NO_JS = [FILE_SRC_GLOB[0], `!${FILE_SRC_GLOB[0]}.js`];
const FILE_DEST_GLOB = 'app';
@brandonpapworth
brandonpapworth / Shit.js
Created December 8, 2015 05:09
Fuck this shit while knowing what "this" is.
'use strict';
function Shit() {
this.fo = 'shizzle';
}
Shit.prototype.fuck = function() {
console.log('Fuck', this, 'shit!');
};