Skip to content

Instantly share code, notes, and snippets.

View ustun's full-sized avatar

Ustun Ozgur ustun

View GitHub Profile
(global-set-key (kbd "S-M-<right>") 'other-frame)
(global-set-key (kbd "S-M-<left>") 'other-frame)
@ustun
ustun / last changed date of a url to datetime object
Created March 15, 2010 15:55
How many days ago a web site was updated
#!/usr/bin/env python
import urllib
from datetime import datetime
response = urllib.urlopen("http://www.bilkent.edu.tr/~kafemud/monu_tr.html")
headers = response.info()
lastchangedDate = datetime.strptime(headers["date"],"%a, %d %b %Y %H:%M:%S %Z")
today = datetime.today()
dayDifference = abs((today-lastchangedDate).days)
if dayDifference > 2:
javascript:(function(){readStyle='style-novel';readSize='size-large';readMargin='margin-medium';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css
@ustun
ustun / gist:8805028
Created February 4, 2014 14:53
Upgrade Postgres.app's databases
export PGDATAOLD="/Users/ustun/Library/Application Support/Postgres/var"
export PGDATANEW="/Users/ustun/Library/Application Support/Postgres93/var"
export PGBINOLD="/Applications/Postgres.app/Contents/MacOS/bin"
export PGBINNEW="/Applications/Postgres93.app/Contents/MacOS/bin"
pg_upgrade
function sendIdToPopupOpener(win, chosenId) {
var name = windowname_to_id(win.name);
var elem = window.opener.document.getElementById(name);
if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
elem.value += ',' + chosenId;
} else {
window.opener.document.getElementById(name).value = chosenId;
}
}
In [1]: u = User(username="foo")
In [2]: u.save()
In [3]: from myapp.models import *
In [4]: my_form = StudentProfileForm({"name": "Foo", "website": "http://foo.com"})
In [5]: my_form.is
my_form.is_bound my_form.is_multipart my_form.is_valid
@ustun
ustun / gist:7b5d2fffa77aa63c24bf
Last active August 29, 2015 14:02
react django
{# react_component.html #}
{% comment %}
Template for a custom template tag for a React component. Includes the jQuery DOM ready call
Props:
- id
- js_mount_callback_name that takes a jquery selector and mounts the component
{% endcomment %}
@ustun
ustun / spinning_mixin.js
Created June 5, 2014 12:01
react spinning mixin
// include http://fgnass.github.io/spin.js/jquery.spin.js first
var SpinningMixin = {
componentWillUpdate: function (nextProps, nextState) {
if (this.state.inProgress && !nextState.inProgress) {
this.stopSpinning();
}
if (!this.state.inProgress && nextState.inProgress) {
@ustun
ustun / boot2docker notes for OS X.md
Last active March 2, 2018 03:37
boot2docker notes for OS X

This document contains some notes I have gathered while I was trying to setup a redis service using boot2docker running on OS X. This won't cover what Docker is, see Docker website for details.

Installing boot2docker

First, install Virtualbox and follow the steps at http://docs.docker.com/installation/mac/

Since Docker only runs on Linux, boot2docker runs a virtual machine in Virtualbox (or VMWare etc), however you can run the docker command on OS X

@ustun
ustun / gist:0c2bb78b27309849b25b
Created August 15, 2014 20:01
emacs packages
./4clojure-20131014.1507
./ac-python-20110519
./ace-jump-mode-20140616.115
./ack-and-a-half-20130815.1917
./anzu-20140703.2228
./archives
./auto-complete-20140803.2118
./blank-mode-20130824.1159
./browse-kill-ring-20140807.720
./buffer-move-20140522.58