Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dweinstein's full-sized avatar

David Weinstein dweinstein

View GitHub Profile
@nowa
nowa / iOS App Store Crawler
Created August 4, 2010 04:19
iOS App Store Crawler
#!/usr/bin/env ruby
# iOS App Store Crawler by Nowa <nowazhu@gmail.com>
# 2010-08-04
require 'rubygems'
require 'hpricot'
require 'open-uri'
USERAGENT = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4'
LETTERS = %w{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z *}
@kentbrew
kentbrew / node-on-ec2-port-80.md
Last active February 4, 2024 19:14
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@dweinstein
dweinstein / cdr.c
Created June 7, 2011 22:04
seek's stream or file before outputting to stdout
/* cdr.c
* David Weinstein (2011)
* offset bytes into a file and write to stdout
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@chrishamant
chrishamant / s3_multipart_upload.py
Created January 3, 2012 19:29
Example of Parallelized Multipart upload using boto
#!/usr/bin/env python
"""Split large file into multiple pieces for upload to S3.
S3 only supports 5Gb files for uploading directly, so for larger CloudBioLinux
box images we need to use boto's multipart file support.
This parallelizes the task over available cores using multiprocessing.
Usage:
s3_multipart_upload.py <file_to_transfer> <bucket_name> [<s3_key_name>]
@bmeck
bmeck / Readme.md
Created April 3, 2012 15:02
Simple Vertical Load Balancing for TCP in Node.js

About

This is the most basic example of vertical scaling by transferring connections to workers, rather than sharing server sockets. It was presented at JSConf US 2012. With this you can create some interesting balancing algorithms that cluster would defer to internal/OS logic.

Exercises

A good first project when working with this is to implement sticky sessions based upon connection.remoteAddress and/or connection.remotePort.

A good advanced project is to change from a TCP based balancer to a HTTP(S) one and balance based upon not just connection.remoteAddress etc. but also on the protocol and/or Host header.

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@teqdruid
teqdruid / Console output -- no Sleep
Created August 7, 2012 20:25
An attempt at making an ARMv7 kernel module for performance counting
# depmod -a; modprobe pmu_sync_sample ; sleep 0; modprobe -r pmu_sync_sample
dmesg output
[91376.479217] Found 6 counters
[91376.479339] Hello, ARM from core 0
[91376.479492] PMNC registers dump:
[91376.479583] PMNC =0x41093001
[91376.479736] CNTENS=0x8000003f
[91376.479827] INTENS=0x00000000
[91376.479919] FLAGS =0x00000000
@tom-go
tom-go / install_theos.sh
Created August 13, 2012 16:15
Theos install script
#!/bin/bash
export THEOS=/opt/theos
# clone theos.git
cd /opt
git clone git://github.com/DHowett/theos.git
# clone iphoneheaders.git
cd $THEOS
mv include include.bak
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: