require "socket"
server = TCPServer.open(2626)
loop do
Thread.fork(server.accept) do |client|
client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
/* Use this to cause a function to fire no more than once every 'ms' milliseconds. | |
For example, an expensive mousemove handler: | |
$('body').mouseover(ratelimit(function(ev) { | |
// ... | |
}, 250)); | |
*/ | |
function ratelimit(fn, ms) { | |
var last = (new Date()).getTime(); |
// Place user-specific overrides in this file, to ensure they're preserved | |
// when upgrading | |
{ | |
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"] | |
} |
As configured in my dotfiles.
start new:
tmux
start new with session name:
/*Copyright(c)2012 relay.github.com http://opensource.org/licenses/MIT*/function Deferred(){this.callbacks=[]} Deferred.prototype={err:0,x:0,$:function(a){this.callbacks.push(a);2==this.x&&this._(this.o);return this},done:function(a){return this.$([a,0])},fail:function(a){return this.$([0,a])},always:function(a){return this.$([0,0,a])},then:function(a,c){return this.$([a,c])},reject:function(a){this.x||(this.err=1,this._(a));return this},resolve:function(a){this.x||this._(a);return this},_:function(a){this.x=1;for(var c=this.err,d=this.callbacks,b=d.shift(),e=a;b;)try{for(;b;){(b=b[2]||(c?b[1]:b[0]))&&(e= b(e||a));if(e instanceof Deferred){var f=this;e.always(function(b){f._(b||a);return b});return}b=d.shift()}}catch(g){c&&(b=d.shift()),this.err=c=1}this.o=e||a;this.x=2}};Deferred.when=function(a,c){if(!c)return a;for(var c=[].slice.call(arguments),a=new Deferred,d=c.length,b=d,e=[],f=function(c){return function(d){e[c]=d;--b||a.resolve(e)}},g=function(b){a.reject(b)};d--;)c[d].then(f(d),g);return a}; |
Ever had the need to create a branch in a repo on Github without wanting (or being able) to access a local repo?
With the aid of [the Github API][1] and any online request app this is a piece of cake!
Just follow these steps:
- Open an online request app (like apirequest.io, hurl.it pipedream.com, reqbin.com, or webhook.site)
- Find the revision you want to branch from. Either on Github itself or by doing a GET request from Hurl:
https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads
- Copy the revision hash
- Do a POST request from Hurl to
https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs
with the following as the POST body :
@font-face { | |
font-family: 'EntypoRegular'; | |
src: url('font/entypo.eot'); | |
src: url('font/entypo.eot?#iefix') format('embedded-opentype'), | |
url('font/entypo.woff') format('woff'), | |
url('font/entypo.ttf') format('truetype'), | |
url('font/entypo.svg#EntypoRegular') format('svg'); | |
font-weight: normal; | |
font-style: normal; | |
} |
Every time I start a new project, I want to pull in a log
function that allows the same functionality as the console.log
, including the full functionality of the Console API.
There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log
was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.
This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:
- The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
#include <stdio.h> | |
#include <windows.h> | |
#include <winsock2.h> | |
int pid = 0; | |
STARTUPINFO lpStartupInfo; | |
PROCESS_INFORMATION lpProcessInformation; | |
BOOL CALLBACK EnumChildWindowsProc(HWND hwnd, LPARAM lparam){ | |
DWORD p; |