Skip to content

Instantly share code, notes, and snippets.

@aweis
aweis / unit_test.rb
Last active August 29, 2015 14:20
timestamps weirdness
#s/ActiveSupport::TestCase/Test::Unit::TestCase works
require 'test_helper'
class ThingTest < ActiveSupport::TestCase
def test_thing
ActiveRecord::Base.uncached do
first = ActiveRecord::Base.connection.query("select now();")
p [Time.now, first]
sleep 3
@aweis
aweis / gist:85ce138c5d9a777df87e
Created May 10, 2015 00:04
url_for bad route...
routes.rb
namespace :manage do
resources :dashboard, :only => [] do
collection do
get 'index'
end
end
end
@aweis
aweis / fun.rb
Created September 28, 2012 14:44
Functional Ruby
#metaprogramming
class Array
def tail
head, *tail = self
return tail
end
def head
head, *tail = self
return head
end
* 07da981 - Revert "Pie in the sky, maybe its a bug in precompiled bullshit" (22 hours ago) <Adam Weis>
* 0282d02 - Pie in the sky, maybe its a bug in precompiled bullshit (22 hours ago) <Adam Weis>
@aweis
aweis / test.txt
Created December 10, 2013 03:44
time rake spec on schedule+ on different versions of ruby Awesome speed improvements!
ruby 1.9.3
rake spec 48.14s user 2.45s system 93% cpu 53.839 total
ruby 2.0.0
rake spec 20.33s user 1.90s system 87% cpu 25.432 total
ruby 2.1.0
rake spec 15.70s user 1.88s system 84% cpu 20.804 total
@aweis
aweis / mersenne.c
Created January 29, 2014 07:45
Find all Mersenne Primes in C given enough memory and time
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
int
isPrime(uintmax_t n) {
if (n < 2) {
return 0;
} else if (n == 2 || n == 3) {
module Mem_store = Irmin_mem.KV(Irmin.Contents.String);
let config = Irmin_mem.config();
let repo = Mem_store.Repo.v(config);
open Lwt.Infix;
let master = config => Mem_store.Repo.v(config) >>= Mem_store.master;
let info = msg => {
U-Boot 1.3.0-rc3-lab126 (Apr 16 2011 - 20:15:23)
CPU: Freescale i.MX35 at 532 MHz
Board: MX35 Luigi [ POR]
WDOG_WCR = 0xff31
WDOG_WMCR = 0x0
Board Id: SP1B000000000000
S/N: B008A0A0118305W4
DRAM: 256 MB
Using default environment
U-Boot 1.3.0-rc3-lab126 (Apr 16 2011 - 20:15:23)
CPU: Freescale i.MX35 at 532 MHz
Board: MX35 Luigi [ POR]
WDOG_WCR = 0xff31
WDOG_WMCR = 0x0
Board Id: SP1B000000000000
S/N: B008A0A0118305W4
DRAM: 256 MB
Using default environment
@aweis
aweis / fixtwitterlinks.js
Created October 1, 2020 00:17
JS to run on twitter.com to remove ?s= params from URLs