Skip to content

Instantly share code, notes, and snippets.

View blakejakopovic's full-sized avatar

Blake Jakopovic blakejakopovic

View GitHub Profile
@chrishulbert
chrishulbert / bcastpacket.m
Created April 6, 2011 01:23
Send a broadcast udp message using c / obj-c
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
- (void)sendBroadcastPacket {
// Open a socket
int sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sd<=0) {
NSLog(@"Error: Could not open socket");
@adeel
adeel / push-notifications.clj
Created July 26, 2011 01:03
Example of sending Apple push notifications with Clojure.
; Depends on [com.notnoop.apns/apns "0.1.6"].
(:import ('com.notnoop.apns APNS))
(defn send-push-notification [device-token message]
(let [service (.build (.withSandboxDestination
(.withCert (APNS/newService) "resources/apns-dev-cert.p12" "password")))
payload (.build (.alertBody (APNS/newPayload) message))]
(.push service device-token payload)))
@benburkert
benburkert / dpkg.rb
Created August 10, 2011 19:36 — forked from jedi4ever/dpkg-gnutar
homebrew formula to get dpkg working on a mac
require 'formula'
class Dpkg <Formula
url 'https://launchpad.net/debian/+archive/primary/+files/dpkg_1.16.0.3.tar.bz2'
homepage 'http://en.wikipedia.org/wiki/Dpkg'
md5 '0266b06ef9da8278cea008d21e17e5f6'
depends_on 'gnu-tar'
def patches
@michiakig
michiakig / three.cljs
Created August 19, 2011 20:53
three.js demo in ClojureScript
(ns three.demo)
(def camera (THREE.Camera. 75 (/ window/innerWidth
window/innerHeight) 1 10000))
(set! (.z (.position camera)) 1000)
(def scene (THREE.Scene.))
(def geometry (THREE.CubeGeometry. 200 200 200))
(def obj (js/Object.))
(set! (.color obj) 0xff0000)
(set! (.wireframe obj) true)
(def material (THREE.MeshBasicMaterial. obj))
@jneira
jneira / express-sample.cljs
Created August 25, 2011 20:07
Clojurescript / node.js basic examples
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@mattsears
mattsears / README.md
Created September 5, 2011 07:41
Gittr: A Git key/value store

Gittr.rb

Git as a key-value store! Build with Grit, it supports SET, GET, KEYS, and DELETE operations. In addition, we can also get the change history of key/values.

And since it's Git, we can easily enhance it to include other awesome Git features such as branches, diffs, reverting, and more!

Example:

@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@yieldthought
yieldthought / .screenrc
Created November 11, 2011 10:42
My .screenrc
#
# Example of a user's .screenrc file
#
# This is how one can set a reattach password:
# password ODSJQf.4IJN7E # "1234"
# no annoying audible bell, please
vbell on
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")