Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
var sys = require('sys');
function request()
{
var host = 'google.com';
var client = http.createClient(443, host, true);
var request = client.request('GET', '/',
{'host': host});
request.end();
@francois2metz
francois2metz / github.json
Created November 25, 2010 13:18
Small part of github API described with SPORE
{
"base_url" : "http://github.com/api/v2/",
"version" : "0.4",
"methods" : {
"user_search" : {
"path" : "/:format/user/search/:search",
"method" : "GET",
"required_params" : [
"format",
"search"
@francois2metz
francois2metz / tmux.conf
Created December 20, 2010 15:10 — forked from oz/tmux.conf
# General config:
# ---------------
setw -g utf8 on
set -g lock-after-time 1800
set-window-option -g automatic-rename off
set -g default-terminal screen
# Look & feel:
# ------------
# Panes colors
@francois2metz
francois2metz / source.txt
Created February 3, 2011 10:27
Add header in all source file
find src/ -name *.erl -exec sh -c "mv '{}' /tmp/plop && cp source.txt '{}' && cat /tmp/plop >> '{}' && rm /tmp/plop" \;
var base64 = require('base64');
var assert = require('assert');
function roundTrip(str) {
assert.equal(base64.decode(base64.encode(new Buffer(str, 'utf8'))), str);
}
['Hello', 'États-Unis'].forEach(roundTrip);
@francois2metz
francois2metz / indextank.js
Created June 13, 2011 16:48
indextank with Node and Spore
// mkdir indextank
// wget https://github.com/SPORE/api-description/blob/master/services/indextank.json
// install node and npm
// npm install spore underscore futures
// edit baseUrl, password and index var
// node indextank.js
var baseUrl = 'http://xxx.api.indextank.com';
var password = 'xxx';
var index = 'test_spore';
@francois2metz
francois2metz / migrator.rb
Created July 20, 2011 17:46
Migrate from drupal to jekyll
#!/usr/bin/env ruby
require 'net/http'
require 'jekyll'
def get_name(title, time)
slug = title.strip.downcase.gsub(/'/, '').gsub(/"/, '').gsub(/(&|&)/, ' and ').gsub(/[\s\.\/\\]/, '-').gsub(/[^\w-]/, '').gsub(/[-_]{2,}/, '-').gsub(/^[-_]/, '').gsub(/[-_]$/, '')
name = time.strftime("%Y-%m-%d-") + slug + '.md'
end
(1..307).each do |node_id|
@francois2metz
francois2metz / testcase.html
Created August 25, 2011 09:00
Testcase to show chrome bug with position fixed
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Chrome bug position fixed</title>
<style type="text/css">
.topbar {
left: 0;
position: fixed;
top: 0;
@francois2metz
francois2metz / downloader.js
Created April 19, 2012 08:50
Download and write to file with node
#!/usr/bin/env node
// modify here
var downloadURL = "http://nodejs.org/dist/v0.6.15/node-v0.6.15.tar.gz"
var dest = "/tmp/result"
// require
var http = require('http')
var url = require('url')
var fs = require('fs')
@francois2metz
francois2metz / parisjs.coffee
Created April 23, 2012 11:21
A simple hubot script @parisjs special node
# This is a simple hubot script
#
module.exports = (robot) ->
robot.respond /do you love javascript\?/i, (msg) ->
msg.send "Yes! But I prefer coffee-script."
msg.finish()
robot.hear /javascript/i, (msg) ->
msg.send "Do you want to say: #{msg.message.text.replace(/javascript/g, 'coffee-script')}"