Skip to content

Instantly share code, notes, and snippets.

View fearofcode's full-sized avatar
🎵
Take that chance / All day long / Fucking up so fucking strong

Warren Henning fearofcode

🎵
Take that chance / All day long / Fucking up so fucking strong
View GitHub Profile
@fearofcode
fearofcode / toy-echo-server.js
Created August 21, 2011 21:47
A toy node.js echo server that disconnects when given the input 'disconnect'
var net = require('net');
var server = net.createServer(function(socket) {
socket.on('data', function(data) {
socket.write(data);
var str = data.toString('utf8');
if(str.indexOf('disconnect') !== -1) {
socket.end('goodbye\n');
@fearofcode
fearofcode / toy-chat-server.js
Created August 21, 2011 22:30
A toy chat server for node.js
net = require('net');
var sockets = [];
var s = net.Server(function(socket) {
sockets.push(socket);
var index = sockets.indexOf(socket);
socket.on('data', function(d) {
@fearofcode
fearofcode / .emacs
Created September 5, 2011 07:55
a minimal .emacs, just a few things for javascript
(tool-bar-mode)
(column-number-mode)
(scroll-bar-mode 0)
(blink-cursor-mode 0)
(set-cursor-color "dark grey")
;disable backup
(setq backup-inhibited t)
;disable auto save
(setq auto-save-default nil)
@fearofcode
fearofcode / gist:1199253
Created September 6, 2011 23:06
dicking around with jquery UI
<h2 class="demoHeaders">Radio buttons with icons</h2>
<div id="radioWithIcons">
<input type="radio" id="radio1" name="radio" /><label for="radio1"><img src="http://www.google.com/favicon.ico"/> Choice 1</label>
<input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2"><img src="http://www.yahoo.com/favicon.ico"/> Choice 2</label>
<input type="radio" id="radio3" name="radio" /><label for="radio3"><img src="http://www.fogcreek.com/favicon.ico"/> Choice 3</label>
</div>
<script type="text/javascript">
$(function(){
@fearofcode
fearofcode / gist:1199356
Created September 7, 2011 00:05
dicking around with tiptip for doing tooltips
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>tiptip test</title>
<link type="text/css" href="tipTip.css" rel="stylesheet" />
<link type="text/css" href="style.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.tipTip.minified.js"></script>
@fearofcode
fearofcode / gist:1202677
Created September 8, 2011 05:12
invoking native libraries from Python via ctypes (Windows)
from ctypes import *
msvcrt = cdll.msvcrt
message_string = "Hello world\n"
msvcrt.printf("Testing: %s", message_string)
@fearofcode
fearofcode / gist:1304595
Created October 21, 2011 18:37
handy script to print out mouse position in Linux (tested on Ubuntu 11.04 64-bit). requires python-xlib
import time
from Xlib import X, display
while True:
d = display.Display()
s = d.screen()
root = s.root
a=root.query_pointer()
b=a._data
print b["root_x"], b["root_y"]
@fearofcode
fearofcode / MongoAddToSet.scala
Created August 3, 2012 22:04
simple example of using $addToSet + $each operator with Java driver from scala
package com.stackmob.mongoaddtoset
import com.mongodb._
import org.bson.types.ObjectId
object MongoAddToSet extends App {
val conn = new Mongo("localhost", 27017)
val db = conn.getDB("addtoset")
val items = db.getCollection("items")
@fearofcode
fearofcode / LearningScala.scala
Created August 14, 2012 05:28
a first try at representing expressions in trees for later use in a gentic programming library
package org.wkh.learningscala
case class GPFunction[T](f: List[T] => T, name: String) {
def apply(x: List[T]) = f(x)
override def toString = name
}
case class GPTerminal[T](f: Map[String, T] => T, name: String) {
@fearofcode
fearofcode / StackMobRequestTests.java
Created August 22, 2012 23:40
Relations workaround for Java/Android SDK
final Dummy dummy = new Dummy("Test 2 - Valdemar");
StackMob.getLogger().setLogging(true);
final SimpleUser user = new SimpleUser("jonh", null);
user.fetchWithDepth(2, new StackMobCallback() {
@Override
public void success(String responseBody) {
StackMob.getLogger().logInfo("Response body when fetching: " + responseBody);