Skip to content

Instantly share code, notes, and snippets.

@meehow
meehow / .gitignore
Created June 16, 2011 10:24
gitignore for empty directories
*
!.gitignore
@meehow
meehow / art.txt
Created June 21, 2011 10:03
ascii art
^__^ /
(oo)\_______/ _________
(__)\ )=( ____|_ \_____
||----w | \ \ \_____ |
|| || || ||
var mobile_url = 'http://m.bankier.pl/art/{ID}/';
var desktop_url = /-(\d+)\.html/;
var agent = navigator.userAgent.toLowerCase();
var isUAMobile =!!(agent.match(/(iPhone|iPod|blackberry|android 0.5|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii)/i));
var isUATablet =!!(agent.match(/(iPad|SCH-I800|xoom|kindle)/i));
var page = document.location.pathname.match(desktop_url);
if (page && (isUAMobile || isUATablet)) {
document.location.href = mobile_url.replace(/{ID}/, page[1]);
}
<?php
if ($_GET) {
$id = $_GET['id'];
} elseif($argv) {
$id = $argv[1];
}
echo $id."\n";
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from profiles.models import UserProfile
class Command(BaseCommand):
def handle(self, *args, **options):
for user in User.objects.all():
try:
import uinput
import time
def sequence(device,t1,t2, t3, t4):
device.emit(uinput.KEY_W, 1) # Press.
time.sleep(t1)
device.emit(uinput.KEY_O, 1) # Press.
time.sleep(t1)
device.emit(uinput.KEY_O, 0) # Release.
device.emit(uinput.KEY_W, 0) # Release.
#!/bin/bash -e
files=$(find . -name "*.php" -o -name "*.html" -o -name "*.htm" -o -name "*.tpl" -o -name "*.js" -o -name "*.txt" -o -name "*.css")
for f in $files; do
iconv -f latin2 -t utf8 "$f" > "$f.utf8"
mv "$f.utf8" "$f"
done
@meehow
meehow / anagram.c
Created December 28, 2013 22:53
Anagram
/* Anagram: a little filter that emits anagrams of its argument.
*
* This program's main point of interest is its speed, which it
* obtains by using native FPU operations to do the anagram tests.
*
* The basic idea is to form a one-to-one mapping of letter values to prime
* numbers, allowing words to be represented as composite numbers by
* multiplying together the primes that map each letter in the word.
* Words formed from the same letters, regardless of order, will then map
* to the same composite number. Also, if one word's number divides exactly
@meehow
meehow / threads.js
Created August 13, 2015 16:12
very basic example of how flow control can be accomplished with generators
var fs = require('fs');
function thread(fn) {
var gen = fn();
function next(err, res) {
var ret = gen.next(res);
if (ret.done) return;
ret.value(next);
}
@meehow
meehow / outbound.js
Last active March 16, 2017 17:02
track outbound links in Google Analytics
var trackOutboundLink = function(event) {
var url = this.href;
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
event.preventDefault();
}
Array.prototype.slice.call(document.getElementsByTagName('a')).map(function(el) {