Skip to content

Instantly share code, notes, and snippets.

View ophentis's full-sized avatar

Willy Tseng ophentis

View GitHub Profile
anonymous
anonymous / simple echo websocket server
Created November 2, 2010 01:48
for nodejs. need do a lot refactoring though.
var net = require('net'),
sys = require('sys');
function WSServer(port, ip) {
if(!port) throw('You should assign a port to listen.');
this.port = port;
this.ip = ip||'127.0.0.1';
this.server = null;
var clients = {};
var state = {
@paulirish
paulirish / data-markdown.user.js
Last active October 22, 2024 14:19
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@btoone
btoone / curl.md
Last active November 3, 2024 23:34
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@domenic
domenic / promises.md
Last active November 19, 2024 02:40
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@termi
termi / crossBrowser_initKeyboardEvent.js
Last active June 13, 2023 02:01
Cross-browser initKeyboardEvent
void function() {//closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@staltz
staltz / introrx.md
Last active November 19, 2024 02:40
The introduction to Reactive Programming you've been missing
@azdle
azdle / example_use.lua
Last active August 29, 2015 14:06
Basic Lua Library for Exosite's JSON RPC API
local exosite = require 'exosite'
local json = require 'dkjson'
local exo = exosite.rpc:new{cik = "9829879a04efb8f4a1b42e22245739678fd4a94e"}
local status, response = exo:create{
"dataport",
{
format = "float",
name = "Temperature",
@csrl
csrl / example_use.lua
Last active August 29, 2015 14:06 — forked from azdle/example_use.lua
local oneprpc = require 'oneprpc'
local json = require 'json'
local rpc = oneprpc:new({cik = "9829879a04efb8f4a1b42e22245739678fd4a94e"})
local status, rid = rpc.create(
"dataport",
{
format = "float",
name = "Temperature",
@craigbeck
craigbeck / introspection-query.graphql
Created April 6, 2016 20:20
Introspection query for GraphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {