Skip to content

Instantly share code, notes, and snippets.

Avatar

Amit Upadhyay amitu

View GitHub Profile
View c.diff
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc
index 5226041..4e5daea 100644
--- a/talk/app/webrtc/peerconnection.cc
+++ b/talk/app/webrtc/peerconnection.cc
@@ -41,6 +41,8 @@
#include "webrtc/base/stringencode.h"
#include "webrtc/system_wrappers/interface/field_trial.h"
+// extern void (*go_Println)(const char*);
+
@amitu
amitu / tyield.js
Last active Aug 29, 2015
node, Q and generators
View tyield.js
// $ npm install q
// $ node --harmony tyield.js
var Q = require("q");
function timeoutPromose(delay) {
var d = Q.defer();
setTimeout(function(){
d.resolve("done");
}, delay);
@amitu
amitu / v
Created Jun 26, 2015
my new browser
View v
#!/bin/sh
set -e
pandoc -s -r html $1 -o /tmp/e.text
if [[ -t 1 ]]; then
less /tmp/e.text
else
cat /tmp/e.text
View 01-datastructures.md

There is plenty we can do with strings, we have already seen .upper() in previous chapter.

>>> message = u"hello world"
>>> message.upper()
u'HELLO WORLD'
View .psqlrc
\pset linestyle unicode
\pset border 2
\set PROMPT1 '%[%033[33;1m%]%x%[%033[0m%]%[%033[1m%]%/%[%033[0m%]%R%# '
\pset pager off
\timing
\pset format wrapped
View Evolution of a Python programmer.py
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@amitu
amitu / Makefile
Created Jul 27, 2015
reload browser on sass change
View Makefile
build:
sassc -I foundation/scss scss/main.scss > css/main.css
osascript reload-chrome.applescript
watch:
make build
fswatch -e main.css scss | xargs -n1 make build
View gist:2012204
<script src="http://cdn.gethammer.co/hammerlib.min.js"></script>
@amitu
amitu / gist:2022131
Created Mar 12, 2012
get username of the process that opened a connection, works only for case when both client and server are on same machine
View gist:2022131
import socket
import time
import commands
soc = socket.socket()
soc.bind(('0.0.0.0', 9996))
soc.listen(5)
while True:
client, address = soc.accept()
@amitu
amitu / demo.html
Created Mar 15, 2012
PingPong HTTP Callbacks base Hammer Application (python using web.py)
View demo.html
<script src="/static/hammerlib.min.js"></script>
<script>
$.fn.on_enter = function (callback) {
var ENTER_KEY = 13;
return this.keypress(function (e){
var key = e.charCode || e.keyCode || 0;
if (key != ENTER_KEY) return;
var value = $(this).val();
if (value === "") return false;
You can’t perform that action at this time.