Skip to content

Instantly share code, notes, and snippets.

@tcard
tcard / gist:939653
Created April 24, 2011 16:02
El peor código que he escrito jamás.
<!-- EL GRAN HERMANO TE VIGILA -->
<?
include('funciones.php');
include('db.php');
arriba(); ?>
<h1>Novedades</h1>
<p class="indent">Un duendecillo con vistosos atuendos se te pone delante volando y empieza a contarte todas las novedades de la semana...</p>
<?
$dia=date("d");
$mes=date("m");
public class Reinas {
public static int reinas(int n) {
int cont = 0;
for (int i=0; i<n; i++) {
List<Integer> lista = new ArrayList<Integer>();
lista.add(i);
cont += reinas(n, lista);
}
import java.util.*;
public class Reinas {
public static int reinas(int n) {
int cont = 0;
for (int i=0; i<n; i++) {
ArrayList<Integer> lista = new ArrayList<Integer>();
lista.add(i);
@tcard
tcard / checktpltags.py
Last active December 23, 2015 06:29
Just quickly wrote this little thingy for debugging ‘unexpected EOF’ errors in Go standard templates.
import os, sys
if len(sys.argv) > 1:
exp = open(sys.argv[1]).read()
else:
exp = raw_input("Write template (or try again with file path as argument): ")
for l in os.sys.stdin:
exp += l
print
@tcard
tcard / goplay.go
Created September 30, 2013 14:41
misc/goplay modified so you can pass gcflags. Eg.: http://cl.ly/image/441U2n0G321W/Image%202013.09.30%2016%3A38%3A50.png
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"flag"
"io/ioutil"
@tcard
tcard / gist:6812768
Created October 3, 2013 16:30
Custom fadeTo.
// Like the fadeTo from jQuery, but doesn't wait until the previous
// animation is over.
var fadeTo = (function() {
var fadingStep = 13;
return function(jqSel, time, toOpacity) {
jqSel.each(function(i, elem) {
if (elem.fadingState != null) {
clearInterval(elem.fadingState.interval);
}
Index: src/stl_logging_unittest.cc
===================================================================
--- src/stl_logging_unittest.cc (revision 136)
+++ src/stl_logging_unittest.cc (working copy)
@@ -31,17 +31,20 @@
#ifdef HAVE_USING_OPERATOR
-#ifdef __GNUC__
+#include <iostream>
The 'go test' command expects to find test, benchmark, and example functions
in the "*_test.go" files corresponding to the package under test.
A test function is one named TestXXX (where XXX is any alphanumeric string
not starting with a lower case letter) and should have the signature,
func TestXXX(t *testing.T) { ... }
A benchmark function is one named BenchmarkXXX and should have the signature,
@tcard
tcard / example.py
Last active August 29, 2015 14:06
Print-based debugger for recursive procedures
# If you run this program:
def fibo(n):
print '>>'
ret = 1 if n == 0 or n == 1 else fibo(n - 1) + fibo(n - 2)
print "Got %d, returning %d." % (n, ret)
print '<<'
return ret
fibo(5)
@tcard
tcard / tagged.go
Last active August 29, 2015 14:27
Tagged unions in Go
package main
import (
"fmt"
"unsafe"
)
// data Shape a = Circle { radius :: a } | Rect { base :: a, height :: a} | Together { left :: Shape a, right :: Shape a }
type ID_shape_float64 struct {
TAG int // Can be 0 (circle), 1 (rect), or 2 (together)