Skip to content

Instantly share code, notes, and snippets.

@graue
graue / pi.clj
Created August 29, 2012 16:46
Clojure code to estimate pi
; for some reason it's not finding clojure.contrib.math
;(ns pi-estimator
; (:require clojure.contrib.math))
; this didn't work either:
;(ns pi-estimator
; (:use [clojure.contrib.math :only [abs]]))
(defn abs [x]
(if (>= x 0)
@graue
graue / Change_Tent.is_background_color.user.js
Created October 16, 2012 15:12
GreaseMonkey script to change Tent.is background color
// ==UserScript==
// @name Change Tent.is background color
// @namespace https://graue.tent.is
// @description Changes the background color of Tent.is pages
// @include https://*.tent.is/*
// @version 1
// @grant none
// ==/UserScript==
document.body.style.background = "limegreen";
@graue
graue / gist:3915735
Created October 19, 2012 01:20
Tentd notification errors
TentD::Model::NotificationSubscription::NotificationError
/home/graue/.bundler/ruby/1.9.1/tentd-0cc6b9802bef/lib/tentd/model/notification_subscription.rb:79:in `notify_about'
/home/graue/.bundler/ruby/1.9.1/tentd-0cc6b9802bef/lib/tentd/model/notification_subscription.rb:70:in `notify'
/home/graue/.bundler/ruby/1.9.1/tentd-0cc6b9802bef/lib/tentd/notifications/girl_friday.rb:15:in `block in <class:Notifications>'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/work_queue.rb:147:in `call'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/work_queue.rb:147:in `block (2 levels) in start'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/actor.rb:86:in `call'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/actor.rb:86:in `block in spawn_link'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/actor.rb:69:in `call'
/var/lib/gems/1.9.1/gems/girl_friday-0.10.0/lib/girl_friday/actor.rb:69:in `block (2 levels) in spawn'
@graue
graue / gist:3970428
Created October 28, 2012 23:28
Change Tent.is background color
// ==UserScript==
// @name Change Tent.is background color
// @namespace https://graue.tent.is
// @description Changes the background color of Tent.is pages
// @include https://*.tent.is/*
// @version 1
// @grant none
// ==/UserScript==
document.body.style.background = "limegreen";
$ curl -s https://shawnj.herokuapp.com/posts/abx606 | pylhon -mjson.too
{
"app": {
"name": "Cocoa Tent Client",
"url": "https://github.com/dustinrue/CocoaTentClient"
},
"attachments": [],
"content": {
"text": "^otherservers.tent.is ^mompracem.tent.is I'm here."
},
@graue
graue / gist:4222064
Created December 6, 2012 05:48
Proving identity via Tent
I've been trying to wrap my head around Tent's app
registration/authentication process and specifically how it works for a
web app.
As I understand it, when someone goes to the web app, puts in
'http://entity.tld' and clicks Sign In, the app:
1. Checks its local database to see if it already has app registration
details for 'http://entity.tld'.
@graue
graue / gist:4230664
Created December 7, 2012 03:59
Tentr should mention the original post when reposting

From Tent's post type docs:

The repost should also include a mention of the original post so that the publisher can see who is reposting her content.

Yet, Tentr doesn't appear to do this. An example repost from 13 hours ago:

$ curl -s https://marco.tent.is/tent/posts/zwvcq9 | python -mjson.tool
{
 "app": {
@graue
graue / powers.rs
Last active December 10, 2015 13:19
Map example in Rust
extern mod std;
fn main() {
let powers = [1, 2, 3, 4].map(|x| *x * *x);
for powers.each |num| {
io::println(int::str(*num));
}
}
/*
@graue
graue / find_even_generic.rs
Created January 3, 2013 08:19
Find first even number in a list (generic version)
extern mod std;
use num::Num;
// Based on some example code by Armin Ronacher
fn find_even<T:Copy Num cmp::Eq>(vec: &[T]) -> Option<T> {
let zero: T = Num::from_int(0);
let two: T = Num::from_int(2);
for vec.each |x| {
if *x % two == zero {
@graue
graue / ConcurrentLua notes.md
Created January 5, 2013 22:59
First thoughts after reading the ConcurrentLua documentation and running the examples

Notes on ConcurrentLua 1.1

2012-Jan-5

(There is no convenient way to view ConcurrentLua's HTML documentation online, so for the time being I uploaded a copy here.)

In ConcurrentLua you apparently have to call a loop function "concurrent.loop()" to start the process. This is unlike Rust where, in your main thread, you simply spawn off a task and it starts running right away. (Does it?)

This seems to be because ConcurrentLua is doing cooperative multitasking (implemented in terms of coroutines), while Rust is doing preemptive multitasking. (Is this correct?) So a task simply keeps running until it begins to wait for a message, at which point another task will run, and so on. (Can this deadlock?)