Skip to content

Instantly share code, notes, and snippets.

@ndarville
ndarville / business-models.md
Last active February 27, 2025 10:00
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@mbostock
mbostock / .block
Last active September 11, 2018 09:45 — forked from mbostock/.block
U.S. TopoJSON
license: gpl-3.0
height: 600
border: no
@extraordinaire
extraordinaire / reconnecting_pdo.php
Last active January 9, 2025 12:21
Reconnectable PDO
<?php
class ReconnectingPDO
{
protected $dsn, $username, $password, $pdo, $driver_options;
public function __construct($dsn, $username = "", $password = "", $driver_options = array())
{
$this->dsn = $dsn;
$this->username = $username;
$this->password = $password;
@devote
devote / PCREConverter.php
Created November 14, 2012 11:58
PCRE Converter
<?php
/**
* Конвертер регулярного выражения
*
* @author Pakhtinov Dmitriy
* @copyright 2012 Pakhtinov Dmitriy
* @data 14.11.2012
*/
class PCREConverter {
@ikbear
ikbear / sortmap.go
Created November 8, 2012 12:59
Sort Map(golang)
package main
// sort a map's keys in descending order of its values.
import "sort"
type sortedMap struct {
m map[string]int
s []string
}
@tracend
tracend / aws_ec2_root.md
Created November 5, 2012 12:02
AWS EC2: Steps to enable root access with your local key - Inspired by: https://forums.aws.amazon.com/thread.jspa?threadID=86876

Note: replace {{server}} with your domain or ip

  • Login as the ec2-user
ssh -i key.pem ec2-user@{{server}}
  • Switch to administrator
sudo -i
@xeoncross
xeoncross / Description.js
Created October 24, 2012 23:26 — forked from tanguylebarzic/Description.js
DKIM signing with Node.js
/*
Heavily inspired by the PHP implementation made by Ahmad Amarullah (available at http://code.google.com/p/php-mail-domain-signer/), with the help of http://phpjs.org/.
Setup:
In dkim-raw-email.js, change the location of your private key and the associatedDomain accordingly to your needs.
Example of use (using aws-lib, https://github.com/mirkok/aws-lib):
@MarcelloDuarte
MarcelloDuarte / dsl.php
Last active October 11, 2015 18:58
Building DSLs
<?php
function describe($testedClass, callable $tests) {
print ("$testedClass" . PHP_EOL);
$tests();
}
function it($testName, callable $test) {
print(" $test" . PHP_EOL);
$test();
@cosimo
cosimo / parse-options.sh
Created September 21, 2012 09:31
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@xeoncross
xeoncross / array.php
Created September 20, 2012 14:31
PHP Form Builder
<?php
function assoc_array_map($cb, $arr) {
$new_array = array();
foreach ($arr as $key => $value) {
array_push($new_array, $cb($key, $value));
}
return $new_array;