Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
int
discover_value(int value)
{
if (value >= '0' && value <= '9') {
return value - '0';
}
return value;
}
@fsouza
fsouza / gist:2760505
Created May 21, 2012 04:01
Go duck typing
package main
import (
"fmt"
)
type Duck interface {
Quak()
Walk()
}
package main
//#include <termios.h>
import "C"
import (
"fmt"
"os"
"syscall"
)
@fsouza
fsouza / gist:2785689
Created May 25, 2012 04:09
the integer miracle
#include <stdio.h>
void
checkMiracle(int x)
{
if (x != 0 && x == -x) {
printf("Miracle!\n");
}
}
@fsouza
fsouza / wma2mp3.csh
Created May 30, 2012 00:41
convert all files in the current directory from wma to mp3, using ffmpeg
#!/bin/csh -ef
foreach file ( *.wma )
set mp3_name = `basename "$file" .wma`.mp3
ffmpeg -i "$file" "$mp3_name"
end
# -*- coding: utf-8 -*-
import time
import csp.csp as csp
@csp.process
def elevator(chan):
while True:
print "Transporting %s" % chan.read()
package main
import (
"github.com/timeredbull/keystoneclient"
)
type MyEc2 keystone.Client
func main() {
println("oi")
package br.ufes.hello;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
[api/app]
% go test -gocheck.v | grep "0\.0[2-9]\ds"
PASS: handler_test.go:379: S.TestAddTeamToTheApp 0.026s
PASS: handler_test.go:252: S.TestAppInfo 0.022s
PASS: handler_test.go:130: S.TestAppList 0.026s
PASS: app_test.go:545: S.TestAppShouldStoreUnits 0.020s
PASS: handler_test.go:1339: S.TestBindHandler 0.021s
PASS: handler_test.go:37: S.TestCloneRepositoryHandler 0.067s
PASS: handler_test.go:72: S.TestCloneRepositoryRunsCloneOrPullThenPreRestartThenRestartThenPosRestartHooksInOrder 0.091s
PASS: app_test.go:51: S.TestDestroy 0.031s
#include <iostream>
void
selection(int v[], int size)
{
int pos, aux;
for(int i = 0; i < size; i++) {
pos = i;
for(int j = i+1; j < size; j++) {
if(v[j] < v[pos]) {