Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Mostly on gitlab.com/dweinstein these days...

David Weinstein dweinstein

💭
Mostly on gitlab.com/dweinstein these days...
View GitHub Profile
@nowa
nowa / iOS App Store Crawler
Created Aug 4, 2010
iOS App Store Crawler
View 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 Oct 27, 2020
How I Got Node.js Talking on EC2's Port 80
View node-on-ec2-port-80.md

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 Jun 7, 2011
seek's stream or file before outputting to stdout
View cdr.c
/* 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 Dec 27, 2011
Instant Server for Current Directory
View gist:1525217
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@chrishamant
chrishamant / s3_multipart_upload.py
Created Jan 3, 2012
Example of Parallelized Multipart upload using boto
View s3_multipart_upload.py
#!/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 Apr 3, 2012
Simple Vertical Load Balancing for TCP in Node.js
View Readme.md

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.

View style_guide.md

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 Aug 7, 2012
An attempt at making an ARMv7 kernel module for performance counting
View Console output -- no Sleep
# 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 Aug 13, 2012
Theos install script
View install_theos.sh
#!/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 Aug 22, 2012
Documenting your REST API
View API.md

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:

You can’t perform that action at this time.