Skip to content

Instantly share code, notes, and snippets.

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;
@crazy2be
crazy2be / WriteInt
Created January 20, 2012 01:30
Shifty bits.go
func WriteInt(wr io.Writer, num uint64) error {
var shifty uint = 64 - 8 // 64 bit integer mines 8 bit integer (byte)
// Our algorithm simply doesn't write anything for a value of zero, but we still need to write something as per the protocol. Handle it as a special case.
if num == 0 {
return writeByte(wr, 0x00)
}
sentFirst := false
func (e *Exception) debugString() (str string) {
defer func() {
if r := recover(); r != nil {
stringer, ok := r.(Stringer)
if !ok {
str = "Panic of non-string type when attempting to create string representation."
return
}
str = stringer.String()
return