Skip to content

Instantly share code, notes, and snippets.

@crazy2be
crazy2be / .bash_profile
Created September 22, 2015 00:09
Add to .bash_profile to get more useful terminal titles.
# http://askubuntu.com/questions/126737/make-gnome-terminal-show-the-command-running-as-title
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
prompt_prefix()
{
if [ "$USER" != "jmcgirr" ] || [ "$HOSTNAME" != "jmcgirr-ld1" ]; then
echo -n "${USER}@${HOSTNAME}: "
else
echo -n
@crazy2be
crazy2be / 0ad-patches.diff
Created August 15, 2015 19:11
A bunch of patches for 0ad to improve gameplay based on our own difficulties/annoyances.
Index: binaries/data/mods/public/simulation/components/Foundation.js
===================================================================
--- binaries/data/mods/public/simulation/components/Foundation.js (revision 16918)
+++ binaries/data/mods/public/simulation/components/Foundation.js (working copy)
@@ -33,6 +33,12 @@
this.maxProgress = 0;
this.initialised = true;
+
+ // Give our foundation a small amount of initial health, so that
observ := observable.NewObservable(g, 0)
observ.OnChanged(g, func(new observable.Object, old observable.Object) {
if new.(int) < 1 {
return
}
fmt.Println("First set", new, "(", old,") call gets", observ.Get());
})
observ.OnChanged(g, func(new observable.Object, old observable.Object) {
if new.(int) < 1 {
@crazy2be
crazy2be / gist:6533353
Created September 12, 2013 05:30
How to write comments :D
/**
* Executes the SQL query on the database
*
* params:
* query: @string the query to execute
*
* returns: The result of the query
*/
SQLDatabase::Query(query) {
@crazy2be
crazy2be / gist:6202377
Created August 10, 2013 22:03
Get a list of files that are affecting your github language statistics, so that you can identify incorrectly counted autogenerated files. A little bit hacky. Probably. I'm not sure, since I don't know ruby that well.
# This file is borrowed from
# https://github.com/github/linguist/blob/master/lib/linguist/repository.rb
# Most of my modifications near the bottom.
# Appologies if the code is difficult to understand, I don't really
# know ruby very well...
require 'linguist/file_blob'
module Linguist
# A Repository is an abstraction of a Grit::Repo or a basic file
# system tree. It holds a list of paths pointing to Blobish objects.
PROCESS (OneMhzModClk) BEGIN
IF (rising_edge(OnMhzModClk)) THEN
CASE state IS
WHEN GFLASH =>
g <= TenMhzModClk;
string intToString(int number) {
char * buffer = new char[10];
sprintf(buffer, "%d", number);
return *(new string(buffer));
}
void debugPrint(ostream& out, HashTable* table, map<int, string> expected) {
out << "**My map state:" << endl;
table->debugPrint(out);
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <map>
using namespace std;
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <map>
using namespace std;
void test(HashTable* table) {
int size = 5;
printf("%s", ((*table)[5]).c_str());
bool errorThrown = false;
map<int, string> expected;
int exp;
int res;