Skip to content

Instantly share code, notes, and snippets.

View rizo's full-sized avatar

Rizo I rizo

  • London, UK
View GitHub Profile
@rizo
rizo / formula.py
Created February 27, 2014 00:43 — forked from gvx/formula.py
"""
formula.py - propositional formulas for Python
by Robin Wellner
Hereby, I waive all rights to this library, as described at <http://creativecommons.org/publicdomain/zero/1.0/>
Examples:
foo = Atom('foo')
bar = Atom('bar')
@rizo
rizo / quotes.md
Last active August 29, 2015 13:57

"Most of the biggest problems in software are problems of misconception."

Rich Hickey in "Hammock Driven Development" at the first Clojure Conj, in Durham, North Carolina on October 23rd, 2010.

Quotes about Jon Skeet

“Jon Skeet doesn't need a debugger, he just stares down the bug until the code confesses” Steven A. Lowe

“When Jon Skeet's code fails to compile the compiler apologises.” Anonymous

import std.stdio;
import std.string;
import std.algorithm;
void main()
{
auto formatHour = (int x) => "%02d".format(x);
auto hours = [0 : "00", 6: "06", 10: "10", 59: "59"];
assert(all!(h => formatHour(h) == hours[h])(hours.keys));
@rizo
rizo / arrow.py
Last active August 29, 2015 13:57
A snippet with an implementation of arrow graphics item in Qt4.
class Arrow(QGraphicsItem):
def __init__(self, parent, position, angle, size = 10.0):
QGraphicsItem.__init__(self)
self._parent = parent
self.setFlag(QGraphicsItem.ItemIsSelectable, False)
self.setFlag(QGraphicsItem.ItemIsMovable, False)
@rizo
rizo / median.d
Created March 25, 2014 15:18
Median implementation in D.
import std.stdio, std.algorithm;
T median(T)(T[] nums) /*pure nothrow*/ {
nums.sort();
if (nums.length & 1)
return nums[$ / 2];
else
return (nums[$ / 2 - 1] + nums[$ / 2]) / 2.0;
}
@rizo
rizo / pairs.js
Created May 16, 2014 13:33
pairs.js
// Requires underscore for zip function.
function slice(array, from, to, step) {
if (from===null) from=0;
if (to===null) to=array.length;
if (!step) return array.slice(from, to);
var result = Array.prototype.slice.call(array, from, to);
if (step < 0) result.reverse();
step = Math.abs(step);
if (step > 1) {
<!doctype html>
<html>
<head>
<link href="http://lab.hakim.se/reveal-js/css/reveal.css" rel="stylesheet"/>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>Single Horizontal Slide</section>
<section>
@rizo
rizo / spark-app-log.txt
Last active August 29, 2015 14:13
Spark Demo Logs
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
15/01/08 15:21:16 INFO CoarseGrainedExecutorBackend: Registered signal handlers for [TERM, HUP, INT]
15/01/08 15:21:17 INFO SecurityManager: Changing view acls to: root,rizo
15/01/08 15:21:17 INFO SecurityManager: Changing modify acls to: root,rizo
15/01/08 15:21:17 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(root, rizo); users with modify permissions: Set(root, rizo)
15/01/08 15:21:17 INFO Slf4jLogger: Slf4jLogger started
15/01/08 15:21:17 INFO Remoting: Starting remoting
15/01/08 15:21:17 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://driverPropsFetcher@188.166.34.149:55071]
15/01/08 15:21:17 INFO Remoting: Remoting now listens on addresses: [akka.tcp://driverPropsFetcher@188.166.34.149:55071]
15/01/08 15:21:17 INFO Utils: Successfully started service 'driverPropsFetcher' on port 55071.
@rizo
rizo / fold-blocks.md
Last active August 29, 2015 14:14
Playground with syntax alternatives for blocks in the Fold programming language.

Block definitions are used for compound expressions, in which the value of the expression is the value of the last expression in the block. Blocks can be used to structure local code inside a function or a module, perform effectful operations and make scoped definitions.

  • function
  • module
  • macro
  • type (?)
Exception in thread "Thread-3" SocketException The transport's socket appears to have lost its connection to the nREPL server
clojure.lang.ExceptionInfo: Subprocess failed {:exit-code 137}
at clojure.core$ex_info.invoke(core.clj:4403)
at leiningen.core.eval$fn__6725.invoke(eval.clj:236)
at clojure.lang.MultiFn.invoke(MultiFn.java:231)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:337)
at leiningen.repl$server$fn__10717.invoke(repl.clj:241)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:624)