Skip to content

Instantly share code, notes, and snippets.

View EdgeCaseBerg's full-sized avatar
📉
Wondering why Github added statuses instead of something useful

Ethan EdgeCaseBerg

📉
Wondering why Github added statuses instead of something useful
View GitHub Profile
@EdgeCaseBerg
EdgeCaseBerg / hillClimber.go
Created May 20, 2014 12:48
Implementation of a Simple Binary Genome hill climber. The fitness is determined simply by how many 1's are turned on in the genome of the child. So a perfect fitness is 100.
package main
import (
"fmt"
"math/rand"
"time"
"runtime"
)
/* HillClimber
@EdgeCaseBerg
EdgeCaseBerg / 21game.cpp
Created October 17, 2014 13:57
A version of the 21 game without proper error checking or rule checking.
#include <stdio.h>
#include <iostream>
using namespace std;
const char * welcometext =
"Welcome to the game of 21! \n\
Rules: \n\
First choose who goes first, the game starts with 21 sticks in\n\
a pile, the player forced to take the last stick loses. \n\
@EdgeCaseBerg
EdgeCaseBerg / 21game-improved.cpp
Last active August 29, 2015 14:07
This is a version of the 21 game with error checking, a computer player, scoreboard, and the ability to play multiple times.
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
const char * welcometext =
"Welcome to the game of 21! \n\
Rules: \n\
First choose who goes first, the game starts with 21 sticks in\n\
@EdgeCaseBerg
EdgeCaseBerg / i3-exit
Last active August 29, 2015 14:13 — forked from jcyamo/i3-exit
#!/usr/bin/env python
# based on cb-exit used in CrunchBang Linux <http://crunchbanglinux.org/>
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
@EdgeCaseBerg
EdgeCaseBerg / ConcurrencyTest.java
Created February 6, 2015 19:01
ConcurrencyTest for timing out and putting a limit on tasks.
import java.util.List;
import java.util.Collection;
import java.util.ArrayList;
import java.util.concurrent.*;
import java.lang.InterruptedException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.CancellationException;
import java.util.Random;
public class ConcurrentTest {
@EdgeCaseBerg
EdgeCaseBerg / event.sh
Last active August 29, 2015 14:16
event.sh file for mcabber to send notifications via notify-send when recieving messages or updates from users.
#!/bin/sh
#set the following in your .mcabberrc file for notifications
#set events_command = ~/.mcabber/event.sh
#set events_ignore_active_window = 0
#set event_log_files = 1
#set event_log_dir = /tmp
if [ $1 = "MSG" ]; then
@EdgeCaseBerg
EdgeCaseBerg / faster.py
Last active August 29, 2015 14:20
Python shell of checking to see which one is faster, addition of strings or interpolation
>>> import dis
>>> def addStr(s):
... return ">" + s + "<"
...
>>> dis.dis(addStr)
2 0 LOAD_CONST 1 ('>')
3 LOAD_FAST 0 (s)
6 BINARY_ADD
7 LOAD_CONST 2 ('<')
10 BINARY_ADD
@EdgeCaseBerg
EdgeCaseBerg / HttpApp.scala
Created May 12, 2015 20:42
Example for multi controller routing in Akka Spray
import akka.io.IO
import akka.actor._
import akka.pattern.ask
import akka.util.Timeout
import spray.http._
import spray.can.Http
import spray.routing._
import spray.routing.RequestContext
import spray.routing.directives.CachingDirectives._
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
// Using vars, lots of local mutation
def getThemVar(th:Throwable)={
var now=th
var li=List[Throwable](now)
var cause=now.getCause
while (cause!=null){
li=cause::li
now=cause
cause=now.getCause
}