Skip to content

Instantly share code, notes, and snippets.

View yorickpeterse's full-sized avatar

Yorick Peterse yorickpeterse

View GitHub Profile
@yorickpeterse
yorickpeterse / fan-control.sh
Last active December 15, 2015 05:49
Poor man's fan control for Macbooks that run Linux.
#!/usr/bin/env bash
set -e
minimum=2000
medium=4500
maximum=6200
value=$minimum
@yorickpeterse
yorickpeterse / ruby-prof.patch
Created July 7, 2013 19:06
Patches to get ruby-prof working with MRI 1.9.3, taken from https://github.com/skaes/rvm-patchsets
diff --git a/gc.c b/gc.c
index 0f84e22..feb54f1 100644
--- a/gc.c
+++ b/gc.c
@@ -98,6 +98,15 @@ ruby_gc_params_t initial_params = {
#endif
};
+#ifndef HAVE_LONG_LONG
+#define LONG_LONG long
@yorickpeterse
yorickpeterse / pomodoro.sh
Created July 16, 2013 09:14
Poor man's Pomodoro timer.
#!/usr/bin/env bash
time=1500 # 25 minutes
title="Pomodoro"
icon=/home/yorickpeterse/Pictures/icons/tomato.png
notify-send -i "$icon" "$title" "Starting a new Pomodoro timer"
sleep $time
@yorickpeterse
yorickpeterse / PKGBUILD
Created July 17, 2013 12:36
PKGBUILD for building Android 4 on Arch Linux.
pkgname=android-4.0.3
pkgver=r03
pkgrel=3
pkgdesc='Platform for Google Android SDK'
arch=('any')
url="http://developer.android.com/sdk/index.html"
license=('custom')
depends=('android-sdk>=r17')
_android_api=android-15
_android_ver=android-4.0.4
@yorickpeterse
yorickpeterse / tag_count.rb
Created January 1, 2014 21:22
Counting the amount of title tags of a sub-reddit. Whipped together to see which ones on /r/r4r get the most comments.
require 'httpclient'
require 'json'
url = 'http://www.reddit.com/r/r4r.json'
after = nil
posts = []
client = HTTPClient.new
tags = {
'[M4F]' => 0,
'[M4M]' => 0,
@yorickpeterse
yorickpeterse / env_madness.md
Created March 3, 2014 10:34
Universal Ruby Environment/Mode Variables

This Gist aims to get some discussion going and throw some ideas around about introducing a more universal way to configure the environment/mode of Ruby applications and libraries (where applicable).

When speaking about the environment/mode (referred to as "environment" from this point on) we're speaking about the variable/option that specifies a alternative set of configuration options to use. That is, separate database options, hostnames and so on. A basic example of this is the standard Rails database configuration file:

@yorickpeterse
yorickpeterse / syntax.rake
Created March 7, 2014 14:35
Checking the syntax of various Ruby related files in a Rails project.
namespace :syntax do
desc 'Checks the syntax of ERB files'
task :erb do
require 'action_view'
Dir['app/views/**/*.erb'].each do |file|
template = File.read(file)
begin
ActionView::Template::Handlers::Erubis \
@yorickpeterse
yorickpeterse / bench_node.sh
Created March 14, 2014 19:32
Accurate proof that Ruby is closer to the bear metal than Node.js
#!/usr/bin/env bash
siege -c 10 -b -t 30s http://localhost:9393
with Rubinius.synchronize:
$ ./bin/benchmark core/file/bench_each_byte.rb
=== rbx ===
File#each_byte with a small file
29.1 (±0.0%) i/s - 146 in 5.023101s (cycle=2)
File#each_byte with a medium file
3.3 (±0.0%) i/s - 17 in 5.228034s (cycle=1)
File#each_byte with a large file
0.3 (±0.0%) i/s - 2 in 6.110730s (cycle=1)
desc: (none)
cmd: ruby rss_growth_during_redis_publish.rb -n 1000000
time_unit: i
#-----------
snapshot=0
#-----------
time=0
mem_heap_B=0
mem_heap_extra_B=0
mem_stacks_B=0