Skip to content

Instantly share code, notes, and snippets.

View willeccles's full-sized avatar
🖤
probably out driving

Will Eccles willeccles

🖤
probably out driving
View GitHub Profile
@ryanflorence
ryanflorence / static_server.js
Last active July 21, 2024 12:43
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@yamaya
yamaya / xcode-clang-vers
Last active June 21, 2024 08:25
Xcode clang version record
# Xcode 4.3.3
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
# Xcode 4.3.2
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
@need12648430
need12648430 / name.js
Last active December 30, 2022 17:45
Pronounceable Seeded Name Generator
function name (id, l) {
function n(){return id=(399*id)%509}
var r="BDGKNPTVZ"[n()%9]
for (var i=1;i<l;i++) r+=i%2?"aeiou"[n()%5]:"bdgknptvz"[n()%9]
return r
};
// id=seed, l=length
function name (id, l) {
// lcg prng
@willeccles
willeccles / pass a method to a method.java
Created August 14, 2015 22:48
This is how to pass a method to another method in Java 8+.
// while this is not technically a method, a Runnable is close enough for me.
// this method wants a "method" as an input
void canHazMethod(Runnable methodToRun) {
// run the method passed in
methodToRun.run();
}
// this is the method I will use:
Runnable myMethod = () -> {
@willeccles
willeccles / methoding.java
Last active August 26, 2015 22:00
an even better way to pass methods as parameters
public static void main(String[] args) {
// this uses a java 8 feature called method references (i think)
// it looks for method "aThingToDo" in class "methoding" (the name of this class)
// aThingToDo must match the pattern, as doAThing says
doAThing(methoding::aThingToDo);
}
// define a pattern for what type of method we want
// we want a method with String s as input and no return (void)
public interface voidMethod {
@CaBra503
CaBra503 / git-cheat-sheet.md
Created December 23, 2015 01:58 — forked from iansheridan/git-cheat-sheet.md
A cheat sheet for GIT

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

@willeccles
willeccles / oodle.cpp
Created October 13, 2016 03:00
Replaces every vowel in given phrase(s) with "oodle"
// compile with:
// g++ oodle.cpp -o oodle -std=c++14
#include <iostream>
#include <string>
#include <regex>
#include <vector>
int main(int argc, char* argv[]) {
if (argc == 1) {
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active July 21, 2024 05:06
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
/* Compile with -DUSE_READLINE and -lreadline to use readline for input. */
#include <arpa/inet.h>
#include <errno.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@willeccles
willeccles / shellandc.c
Last active February 24, 2023 01:52
A C program which is also a valid bash script, and vice versa.
#include <stdio.h>
#define $x ,x
#define $i ,i
#define eval int
#define read scanf
#define $scanfpat "%d", &
#define $(x) ,(x)
#define $open (
#define $close )
#define do {