Skip to content

Instantly share code, notes, and snippets.

View stefek99's full-sized avatar
🦄
Rainbows. Lasers. Unicorns.

Michal Stefanow stefek99

🦄
Rainbows. Lasers. Unicorns.
View GitHub Profile
<Response>
<Pause length="4"/>
<Play>http://stefanow.net/stuff/twilio/record/50.wav</Play>
</Response>
@stefek99
stefek99 / jquery.ba-tinypubsub.js
Created October 3, 2012 10:32 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@stefek99
stefek99 / app.js
Created December 9, 2012 14:18
Raspberry Pi Makey Makey WiFi NodeJS sound transmitter
var app = require('express').createServer(), io = require('socket.io').listen(app);
var url = require("url");
globalsocket = "XXX";
io.set('log level', 1); // reduce logging
app.listen(3000);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
@stefek99
stefek99 / interact.js
Created February 23, 2013 11:44
PhantomJS - Performing a series of page interactions. Code from: https://groups.google.com/forum/#!topic/phantomjs/20z8N8rwITw (thanks to respective owners) Opened issue number 1 here: https://github.com/bacey/phasmine/issues/1 (phasmine does not work for me as expected) Usage: put all three files into same directory and phantomjs phantom.js
var pageNum = 1;
function interact (page,callback_list) {
console.log("Setting onLoadFinished");
page.onLoadFinished = function (status) {
// For debugging, log the results and render the page to a temp directory
console.log (status + ":" + pageNum + " Page load complete - " +
page.evaluate(function() {
return document.title + " - " + document.location.href;
@stefek99
stefek99 / contentscript.js
Last active December 15, 2015 15:29
Playing around with Chrome Extensions - Workflowy on steroids (ma favourite web app)
console.log("Using included jQuery! " + document.location.href + " " + jQuery.fn.jquery);
var $nativeInput;
var totalTextareas = 2;
var eventsAssigned = 0;
$(document).on("keydown.textarea", "textarea", function(e) {
console.log("window keydown: " + e.keyCode);
var $maybeTextarea = $(document.activeElement);
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo Resize</title>
<script src="js/canvasresize/jquery-1.7.2.min.js"></script>
<script src="js/canvasresize/jquery.exif.js"></script>
<script src="js/canvasresize/jquery.canvasResize.js"></script>
<script src="js/canvasresize/canvasResize.js"></script>
<script src="js/canvasresize/binaryajax.js"></script>
@stefek99
stefek99 / snippet.js
Created July 15, 2013 15:55
Debugging mouse events is tricky as sometimes switching context to developer tools closes the popup.
if(e != null && e.type.indexOf("mouse") == -1)
{
counter++;
}
if(counter == 4)
{
debugger;
}
@stefek99
stefek99 / gist:9074068
Created February 18, 2014 16:15
Very simple timestamp. Sortable output ```20141181-1392740100138```
var _filename = function() {
var now = new Date();
return now.getFullYear() + ('0' + now.getMonth()+1).slice(-2) + ('0' + now.getDate()+1).slice(-2) + "-" + now.getTime();
}
@stefek99
stefek99 / gist:9420591
Created March 7, 2014 21:31
gruntfile.js
// Generated on 2014-01-23 using generator-mobile 0.0.2
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
@stefek99
stefek99 / README.md
Last active September 18, 2017 01:45
Old answer (removed from StackOverflow)

Originally it was here: http://stackoverflow.com/a/11818691/775359

Piece of working code

(I'm sure it will help)

Well... Many things have changes since then and I believe it is worth keeping things up to date :)