Skip to content

Instantly share code, notes, and snippets.

@piatra
piatra / app.js
Created June 7, 2012 08:59 — forked from max-mapper/app.js
github oauth with tako and leveldb
var path = require('path')
var tako = require('tako')
var gist = require('gist')
var request = require('request')
var qs = require('querystring')
var leveldb = require('leveldb')
var https = require('https')
var htmldir = path.resolve(__dirname, 'attachments')
@paulirish
paulirish / gist:2926904
Created June 13, 2012 22:31
My SublimeLinter.sublime-settings file
{
"// my options for SublimeLinter " : "//",
"jshint_options" : {
"boss": true,
"browser": true,
"curly": false,
"devel": true,
"eqeqeq": false,
"eqnull": true,
// create pub-sub functionality
Backbone.pubSub = _.extend({}, Backbone.Events);
// view one needs to trigger an event in view2
View1 = Backbone.View.extend({
triggerView2Event : function() {
Backbone.pubSub.trigger('view2event', { 'some' : 'data' } );
})
@shuhaowu
shuhaowu / relative_time.js
Last active October 12, 2015 07:48
Relative time helper like twitter in JavaScript
var relative_time = function(timestamp, relative_to) {
if (timestamp === null || timestamp === undefined)
return "";
var delta, relative_is_future, t;
if (!relative_to)
relative_to = parseInt(new Date().getTime() / 1000);
if ($.type(timestamp) !== "number")
@max-mapper
max-mapper / readme.md
Created December 6, 2012 20:50
hybrid app article topics
  • touch events to make web apps feel fast
  • default mobile css overrides (-webkit-touch-callout: none; etc)
  • using zepto to make mobile web apps
  • client side templating and routing for quick loading apps
  • supporting retina devices with sprites
  • css3 flexible box model and column layouts for responsive web apps
  • using phonegap to deploy web apps as native
  • web first development workflow (chrome dev tools, safari debugging)
  • how to submit a web app to the app store + google play
  • cross platform mobile code via feature detection
@brianleroux
brianleroux / gruntfile.js
Created August 27, 2013 17:35
calling `npm test` from `grunt test`
var shell = require('shelljs')
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
})
grunt.registerTask('default', 'My "default" task description.', function() {
grunt.log.writeln('Currently running the "default" task.');
@nchevobbe
nchevobbe / screenshot.js
Last active September 4, 2018 13:22
Log a data URL containing a screenshot of the window
let canvas = window.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas");
let context = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
context.drawWindow(window, 0, 0, canvas.width, canvas.height, "white");
console.log(`
📸 📸 📸 📸
${canvas.toDataURL()}
@max-mapper
max-mapper / readme.md
Last active June 3, 2020 00:31
automatically scan for and join open internet enabled wifi networks on linux using node.js (tested on raspberry pi raspbian)
@domenic
domenic / 1-Domenic.js
Last active September 30, 2021 15:43
How DI container config should work (in JS)
"use strict";
// Domenic needs a Tweeter
function Domenic(tweeter) {
this.tweeter = tweeter;
}
Domenic.inject = ["tweeter"];
Domenic.prototype.doSomethingCool = function () {
return this.tweeter.tweet("Did something cool!");
<!DOCTYPE>
<html>
<head>
<title>Dissecting Gmail's Email Attachments - Dropping Files</title>
<style>
.msg {
display: none
}
.dragging .msg {