Skip to content

Instantly share code, notes, and snippets.

Scott Feeney graue

Block or report user

Report or block graue

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@graue
graue / pi.clj
Created Aug 29, 2012
Clojure code to estimate pi
View pi.clj
; 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 Oct 16, 2012
GreaseMonkey script to change Tent.is background color
View Change_Tent.is_background_color.user.js
// ==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 Oct 19, 2012
Tentd notification errors
View gist:3915735
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 Oct 28, 2012
Change Tent.is background color
View gist:3970428
// ==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";
View gist:3977799
$ 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 Dec 6, 2012
Proving identity via Tent
View gist:4222064
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 Dec 7, 2012
Tentr should mention the original post when reposting
View gist:4230664

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 Dec 10, 2015
Map example in Rust
View powers.rs
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 Jan 3, 2013
Find first even number in a list (generic version)
View find_even_generic.rs
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 Jan 5, 2013
First thoughts after reading the ConcurrentLua documentation and running the examples
View ConcurrentLua notes.md

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?)

You can’t perform that action at this time.