Skip to content

Instantly share code, notes, and snippets.

View flashingpumpkin's full-sized avatar
🏠
Working from home

Alen Mujezinovic flashingpumpkin

🏠
Working from home
View GitHub Profile
package test.zipper
object TreeZipper extends App {
println("hello")
// exp 2 * 3 + 4 * 6
val _2 = Node("2", Nil)
val _3 = Node("3", Nil)
#!/usr/bin/env ruby
require "rubygems"
require "spidr"
require "open-uri"
=begin
= CSS snowball
Rolls through your site, picking up style attributes and making you
a new stylesheet. Once you've got your stylesheet, run it through
object ApplicationBuild extends Build {
val appName = "society20-app"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
"commons-codec" % "commons-codec" % "1.6")
val main = PlayProject( appName, appVersion, appDependencies, mainLang = SCALA ).settings()
}

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
/*global angular: true, google: true, _ : true */
'use strict';
angular.module('geocoder', ['ngStorage']).factory('Geocoder', function ($localStorage, $q, $timeout) {
var locations = $localStorage.locations ? JSON.parse($localStorage.locations) : {};
var queue = [];
// Amount of time (in milliseconds) to pause between each trip to the
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@flashingpumpkin
flashingpumpkin / latency.txt
Created May 31, 2012 18:21 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@flashingpumpkin
flashingpumpkin / hack.sh
Created March 31, 2012 16:10 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@flashingpumpkin
flashingpumpkin / gist:1684093
Created January 26, 2012 18:06 — forked from leafo/gist:1683661
screenshot sharing
#!/bin/bash
scrot '%Y-%m-%d_%H-%M-%S.png' -s -e 'scp $f leaf@leafo.net:www/shotsnb;echo -n "http://leafo.net/shotsnb/$f" | xclip; rm $f'
notify-send -u normal -t 1000 'Screenshot Ready'