Skip to content

Instantly share code, notes, and snippets.

@adeel
adeel / aak-layout.sty
Created April 3, 2013 03:48
new latex style files
\ProvidesPackage{aak-layout}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}
\RequirePackage[
textheight=0.7\paperheight,
textwidth =0.7\paperwidth,
top =0.1\paperheight,
bottom =0.2\paperheight,
left =0.1\paperwidth,
import pytz
def localize(date, time_zone):
"Convert the date to the local time zone (from UTC)."
return date.replace(second=0, microsecond=0,
tzinfo=pytz.utc).astimezone(pytz.timezone(time_zone))
def to_utc(date, time_zone):
"Change a datetime corresponding to the time_zone to UTC time."
(ns stopwatch.logger
(:use [clojure.string :only (split-lines)]
[stopwatch.util :only (get-log-path)])
(:require [cljs.nodejs :as node]))
(def fs (node/require "fs"))
(def moment (node/require "moment"))
(defn- parse-datetime [date]
(.toDate (moment date "HH:mm \\o\\n DD.MM.YYYY")))
(defn delta-seq [xs]
(map
(fn [i]
(let [x (nth xs i)
x* (nth xs (inc i))]
(- x* x)))
(range (dec (count xs)))))
@adeel
adeel / gist:2714352
Created May 16, 2012 22:06
HTML helpers
(use 'hiccup.core)
(defn text-field
([field-name title] (text-field field-name title {}))
([field-name title {:keys [password? guide value]}]
(let [id (str (name field-name) "-field")]
[:div.field-wrapper
[:div.field
[:label {:for id} title]
[:input.text {:type (if password? "password" "text")
var fun = (function() {
var self = {};
self.element = (function() {
var self = {};
self.events = (function() {
// Based on http://dean.edwards.name/my/events.js.
var self = {};
@adeel
adeel / veneer.css
Created November 16, 2011 00:24
veneer: a lightbox (uses MooTools)
.veneer_overlay {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.5;
opacity: 0.5;
@adeel
adeel / gist:1240589
Created September 25, 2011 13:11
Null-route Facebook netblocks
#!/usr/bin/env python2
# http://bgp.he.net/AS32934#_prefixes
import os
netblocks = [
"31.13.24.0/21",
"66.220.144.0/21",
"66.220.152.0/21",
"69.63.176.0/21",
@adeel
adeel / gist:1164481
Created August 23, 2011 06:30
Example: Heroku + Node.js + Express.js + connect-mongodb
var mongo = require('mongodb'),
mongoStore = require('connect-mongodb');
var mongo_config = {
host: "staff.mongohq.com",
port: 10004,
dbname: "appXXX",
username: "username",
password: "password"};
@adeel
adeel / UITextField+withFrame.h
Created July 28, 2011 19:00
UITextField category for conveniently adding text fields inside frames with padding.
//
// UITextField+withFrame.h
//
#import <Foundation/Foundation.h>
@interface UITextField (withFrame)
+ (UITextField *)textFieldWithFrame:(CGRect)frame