Skip to content

Instantly share code, notes, and snippets.

View cem2ran's full-sized avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
@codiez
codiez / itunes_notifications.py
Created December 20, 2009 20:14
Listen for distributed notifications from iTunes of the current song
'''
This python script listens for distributed notifications from iTunes of new songs playing,
works alot better then constantly polling.
'''
import Foundation
from AppKit import *
from PyObjCTools import AppHelper
class GetSongs(NSObject):
def getMySongs_(self, song):
@adamloving
adamloving / fb-fan-export.js
Created January 18, 2011 01:02
Export Facebook Page Fans
/*
For more detailed instructions on how to use this script, sign up with your email here:
http://adamloving.com/internet-programming/how-toexport-facebook-page-fans
DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I've had no problem running this so far for 1000s of page fans, but I
@nilcolor
nilcolor / Node.js CORS
Created February 8, 2011 15:28
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@armon
armon / facebook.py
Created May 20, 2011 07:17
Facebook interface to get posts and perform hierarchical user clustering
from collections import defaultdict
from math import sqrt
import httplib2
import json
import re
import threadpool
import threading
from PIL import Image,ImageDraw
ACCESS_TOKEN = "..."
@jeherve
jeherve / in-header.php
Created July 23, 2011 19:11
fb:image handled by WordPress custom fields
<?php if ( get_post_meta($post->ID, 'fbimage', true) ) : ?>
<meta property="og:image" content="<?php echo(get_post_meta($post->ID, "fbimage", true)); ?>" />
<?php endif; ?>
@coryalder
coryalder / blogpost.md
Created August 17, 2011 07:37
Extract html book files from the safari books online iPad app "Safari To Go" using php.

Save books out of Safari Books Online

From http://objectivesea.tumblr.com/post/9033067018/safaribooks

This is hard. I spent way too much time figuring this out, because I was annoyed that a book I bought (Addison-Wesley) was available online for free, except only for 45 days after which payment was required. So I made this hack... probably useful to no one else, but here it is.

Requirements:

  1. iPad.
  2. Safari To Go (the Safari Books Online iPad app).
@un33k
un33k / sed cheatsheet
Created August 22, 2011 13:28
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@fogus
fogus / trampoline.ml
Created September 17, 2011 23:52 — forked from rapha/trampoline.ml
Trampolining in OCaml
(* translated from http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html *)
(* implement trampolining *)
type 'a bounce = Done of 'a | Call of (unit -> 'a bounce)
let rec trampoline = function
| Call thunk -> trampoline (thunk())
| Done x -> x
(* define some functions which use them *)
<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/example#">
<meta property="fb:app_id" content="YOUR_APP_ID" />
<meta property="og:url" content="http://example.vom/cookie.html">
<meta property="og:type" content="example:recipe" />
<meta property="og:title" content="Oreo Stuffed Cookies" />
<meta property="og:image" content="http://example.com/cookie.jpg" />
<meta property="og:description" content="The Turducken of Cookies" />