Skip to content

Instantly share code, notes, and snippets.

View strax's full-sized avatar

Sami Kukkonen strax

View GitHub Profile
@strax
strax / gist:1374459
Created November 17, 2011 20:43
First negative element of an array, recursively
public int firstNegative(int[] numbers, int...i) {
return ((i = (i != null ? i : 0)) > numbers.length())
? 0
: ((numbers[i] < 0)
? numbers[i]
: firstNegative(numbers, i+1));
}
(defn relay [x i]
(when (:next x)
(send (:next x) relay i))
(when (and (zero? i) (:report-queue x))
(.put (:report-queue x) i))
x)
(defn run [m n]
(let [q (new java.util.concurrent.SynchronousQueue)
hd (reduce (fn [next _] (agent {:next next}))
@strax
strax / index.html
Created November 6, 2011 18:01
Sample login dialog
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Login</title>
<link rel="stylesheet" type="text/css" media="screen, projection" href="screen.css">
</head>
<body>
<div class="dialog" id="new-session-dialog">
<h1>Login</h1>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Checkout details &mdash; Cloudchat</title>
<link href="screen.css" media="screen, projection" rel="stylesheet" type="text/css">
</head>
<body id="checkout">
<section class="dialog">
<header>
unction $bind1_0(fn, thisObj, scope) {
return function() {
return fn.call(thisObj, scope);
}
}
function $bind1_1(fn, thisObj, scope) {
return function(arg) {
return fn.call(thisObj, scope, arg);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "uv/uv.h"
static uv_tcp_t server;
void on_close(uv_handle_t* handle) {
// release the handle
free(handle);
@strax
strax / LICENSE.txt
Created May 31, 2011 12:36 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@strax
strax / app.rb
Created March 27, 2011 12:52 — forked from nmerouze/app.rb
gem "mongoid", ">= 2.0.0.beta9"
gem "bson_ext", ">= 1.0.3"
gem "haml", ">= 3.0.12"
gem "rspec-rails", ">= 2.0.0.beta.15", :group => :test
generators = <<-GENERATORS
config.generators do |g|
g.orm :mongoid
g.template_engine :haml
g.test_framework :rspec, :fixture => true, :views => false
var depth = 1, invocations = 0, substractions = 0, edge = 0;
function f(x, y, z) {
if(y < x) {
// Increment the counters
++depth
substractions += 3
if(depth > edge) edge = depth
console.log("Recursion depth: %d", depth)
var depth = 0;
function f(x, y, z) {
if(y < x) {
++depth
console.log("Recursion depth: %d", depth)
z = f(f(x - 1, y, z), f(y - 1, z, x), f(z - 1, x, y))
--depth
}
return z