Skip to content

Instantly share code, notes, and snippets.

View elazar's full-sized avatar

Matthew Turland elazar

View GitHub Profile
@ralphschindler
ralphschindler / tree.php
Created April 21, 2010 14:42
'tree' console command, in PHP.
#!/usr/bin/php
<?php
/**
* Because you want "tree", but cannot find the source code quick enough
* on the web to compile for OS.X or there is no suitable implementation
* on windows.
*/
// set error reporting
error_reporting(E_STRICT | E_ALL);
@grahamc
grahamc / call.php
Created December 6, 2011 15:45
Robocall a whole bunch of people from PayPal about this Regretsy disaster.
<?php
// Note: CA state law says no robocalls before 9AM, so wait until 12PM EST.
$sid = 'Your SID';
$token = 'Your Token';
$telephoneNumber = 'Your Telephone Number, the one that Twilio gives you.';
$client = new Services_Twilio($sid, $token);
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@codeinthehole
codeinthehole / portforward.sh
Last active August 6, 2023 22:02
Bash helper function for easier port forwarding - should be added to your ~/.bashrc
# Easier port forwarding - usage:
#
# $ portforward project-app1 5432
#
# where 'project-app1' is an alias from ~/.ssh/config and 5432 is the remote
# port that you want to forward to.
function portforward() {
HOST=$1
REMOTE_PORT=$2
# Pick a random port and check it is free
@phuedx
phuedx / call-me-maybe.php
Last active December 14, 2015 13:38
Hey, I've just called you, And this is crazy, But I misspelled you, So proxy, maybe?
<?php
class CallMeMaybe
{
public function __call($name, $arguments)
{
$class = new ReflectionClass($this);
$weightedMethods = array();
foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@AdrianSchneider
AdrianSchneider / next-port
Last active December 31, 2015 21:29
PHP built-in server on next unused port seq 8000 65000 defines the port range
#!/bin/sh
for port in $(seq 8000 65000); do echo -ne "\035" | telnet 127.0.0.1 $port > /dev/null 2>&1; [ $? -eq 1 ] && echo "$port" && break; done
@staltz
staltz / introrx.md
Last active July 26, 2024 04:24
The introduction to Reactive Programming you've been missing
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@tswicegood
tswicegood / environment.yml
Last active November 17, 2021 23:22
Simple scraper for looking through a bunch of saved Craigslist listings for a phone number
# Conda environment file -- these packages are required for this script to work
name: craigslist
dependencies:
- lxml
- pip
- python=3.4*
- requests
- pip:
- aiohttp
- pyquery