Skip to content

Instantly share code, notes, and snippets.

View mhenrixon's full-sized avatar
🐢
I may be slow to respond.

Mikael Henriksson mhenrixon

🐢
I may be slow to respond.
View GitHub Profile
@mhenrixon
mhenrixon / 0-readme.md
Last active December 14, 2015 02:48 — forked from kenmazaika/0-readme.md

ruby-1.9.3-p385 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p385 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@mhenrixon
mhenrixon / players.html
Last active December 14, 2015 04:38
How to dynamically render lists grouped by column values
<h1>{{ list_row.name }}</h1>
{% capture get_slug %}get_{{ list_slug }}{% endcapture %}
{% for row in lists[get_slug].position_Målvakt %}
{{ row | row_link: 'name' }}
{% endfor %}
{% for row in lists[get_slug].position_Backar %}
{{ row | row_link: 'name' }}
@mhenrixon
mhenrixon / c_sharp_loop.cs
Created February 27, 2013 14:00
Ruby vs C#
int sum = 0;
for (int i = 0; i < 5; i++)
{
Console.Write(i.ToString() + " ");
}
@mhenrixon
mhenrixon / cookies.js
Created March 1, 2013 13:25
Reading cookies
var cookies;
cookies = void 0;
this.readCookie = function(name, c, C, i) {
if (cookies) {
return cookies[name];
}
c = document.cookie.split("; ");
cookies = {};
@mhenrixon
mhenrixon / calendar_spec.rb
Created March 1, 2013 15:13
testing finders
require 'spec_helper'
describe Calendar do
let(:partner) { create :partner}
let(:site_two) { create :site, partner: partner }
let(:calendar) { create :calendar, name: 'Whatever', site: site_two }
before { calendar }
describe "finders" do
it "finds #upcoming events" do
common: &default_settings
adapter: mysql2
host: localhost
username: root
encoding: utf8
reconnect: false
pool: 5
development:
<<: *default_settings
# Example usage:
require 'active_record/nonpersisted_attribute_methods'
class Node < ActiveRecord::Base
include ActiveRecord::NonPersistedAttributeMethods
define_nonpersisted_attribute_methods [:bar]
# Example of using with ancestry and getting :parent to show up in changes hash.
has_ancestry
define_nonpersisted_attribute_methods [:parent]
@mhenrixon
mhenrixon / uninstall_gems.sh
Created March 8, 2013 09:11
Uninstalls all gems under ruby 2.0. This way the system gems won't halt the uninstallation process upon throwing exceptions
for gem in `gem list --no-version`; do
gem uninstall -aIx $gem
done
@mhenrixon
mhenrixon / pkill.sh
Created March 10, 2013 13:32
How to kill all processes with a specific name (no questions asked)
#!/bin/sh
for X in `ps acx | grep -i $1 | awk {'print $1'}`; do
kill $X;
done
@mhenrixon
mhenrixon / getJSON.js
Created March 15, 2013 10:23
fetching widgets
$.getJSON("/admin/widgets", function(data) {
$.each(data, function(index, object) {
var widget = object.table;
console.log('widget id:' + widget.id, + ', name' + widget.name);
});
});