Skip to content

Instantly share code, notes, and snippets.

/*
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU LGPLv2.
See the file COPYING.LIB.
*/
#ifndef _FUSE_LOWLEVEL_H_
#define _FUSE_LOWLEVEL_H_
@pgriess
pgriess / sendfile.js
Created September 16, 2010 20:53
Using sendfile(2) with NodeJS
var assert = require('assert');
var net = require('net');
var open = process.binding('fs').open;
var sendfile = process.binding('fs').sendfile;
if (process.argv.length < 4) {
console.error('usage: sendfile <port> <path>');
process.exit(1);
}
#!/usr/bin/env node
// requires node v0.3
// telnet.js 80 google.com
net = require('net');
a = process.argv.slice(2);
if (!a.length) {
console.error("telnet.js port [ host=localhost ]");
process.exit(1);
}
s = require('net').Stream();
@creationix
creationix / server.js
Created January 4, 2011 05:13
creationix.com with new node unstable https apis.s
var secure = __dirname + "/secure/";
var handler = require('stack')(
require('creationix/log')(),
require('creationix/auth')(/^\/secure\//, require(secure + "users.js")),
require('creationix/static')("/", __dirname, "index.html")
);
var read = require('fs').readFileSync;
var options = {
@DanBUK
DanBUK / net.Stream.setConnTimeout.hack.js
Created January 11, 2011 22:55
This hack enables node.js to handle connection timeouts.
var net = require('net');
var sys = require('sys');
// START setConnTimeout hack
net.Stream.prototype._orig_connect = net.Stream.prototype.connect;
net.Stream.prototype.connect = function () {
var self = this;
if (typeof self.conn_timeout !== 'undefined' && self.conn_timeout > 0) {
self.addListener('connect', function () {
clearTimeout(self.conn_timer);
@draeton
draeton / anchor.js
Created January 9, 2012 15:15
Anchor - A URL parsing utility
/**
* Anchor - A URL parsing utility
*
* Copyright 2012, Matthew Cobbs
* MIT licensed
*
* Methods:
*
* getSearchVars - returns a key-value object with the parameters in the URL search
* setSearchVars(o) - sets parameters using a key-value object in the URL search
@bartlomiejdanek
bartlomiejdanek / git-remove-file.sh
Created January 10, 2012 10:23
remove file from git history
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@spikebike
spikebike / client.go
Created March 29, 2012 01:13
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@L422Y
L422Y / osx_automount_nfs.md
Last active May 10, 2024 09:06
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service

@denji
denji / golang-tls.md
Last active June 13, 2024 10:07 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)