Skip to content

Instantly share code, notes, and snippets.

View daluu's full-sized avatar

David Luu daluu

View GitHub Profile
@nolim1t
nolim1t / socket.c
Created June 10, 2009 03:14
HTTP Request in C using low level write to socket functionality
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
@mzp
mzp / echo.html
Created December 11, 2010 01:30
websocket.py
<html>
<head>
<style type="text/css">
.log {
color: red;
}
</style>
<script>
ws = new WebSocket("ws://localhost:8080");
ws.onopen = function (e) {
@hubgit
hubgit / xhr-binary.js
Created December 15, 2010 17:09
Binary file XHR getting and sending that works in Chrome 9 and Firefox
// https://developer.mozilla.org/en/using_xmlhttprequest
// http://web.archive.org/web/20071103070418/http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html
function getBinary(file){
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
@nolim1t
nolim1t / gist:752788
Created December 23, 2010 09:53
Running a Sikuli script from the shell (OS X)
#!/bin/bash
# do shell script "/Applications/Sikuli-IDE.app/sikuli-ide.sh -r /Users/nolim1t/Documents/randomscript.sikuli"
/Applications/Sikuli-IDE.app/sikuli-ide.sh -r /Users/nolim1t/Documents/somescript.sikuli
@border
border / Makefile
Created January 12, 2011 01:36
json example in golang
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
@krohrbaugh
krohrbaugh / google_analytics_example.html
Created January 19, 2011 20:00
Google Analytics include code using protocol-relative URLs => http://bit.ly/fomkTv
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'YOUR_ID_HERE']);
_gaq.push(['_trackPageview']);
</script>
<script src="//www.google-analytics.com/ga.js" type="text/javascript" async></script>
@dnedbaylo
dnedbaylo / PersistentWebdriver.py
Created March 3, 2011 09:39
PersistentWebdriver
from selenium import webdriver
from selenium.webdriver.remote.remote_connection import RemoteConnection
from selenium.webdriver.remote.errorhandler import ErrorHandler
from selenium.webdriver.remote.command import Command
class PersistentWebdriver (webdriver.Remote):
def __init__(self, session_id=None, browser_name=''):
command_executor='http://localhost:4444/wd/hub'
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@granoeste
granoeste / gist:858096
Created March 7, 2011 05:01
[Android] Phone State Listener
public class SignalStrengthListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
boolean isGsm = signalStrength.isGsm();
// Get the CDMA RSSI value in dBm
int iCdmaDbm = signalStrength.getCdmaDbm();
// Get the CDMA Ec/Io value in dB*10
@j1n3l0
j1n3l0 / gist:862072
Created March 9, 2011 11:49
Various failures installing stuff with Bundler
$ gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/software/team87/brave_new_world/app/ruby-1.8.7-p174/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes