Skip to content

Instantly share code, notes, and snippets.

@forest
forest / natcmp.rb
Created July 17, 2013 18:58
Natural order comparison of two strings
# natcmp.rb
#
# Natural order comparison of two strings
# e.g. "my_prog_v1.1.0" < "my_prog_v1.2.0" < "my_prog_v1.10.0"
# which does not follow alphabetically
#
# Based on Martin Pool's "Natural Order String Comparison" originally written in C
# http://sourcefrog.net/projects/natsort/
#
# This implementation is Copyright (C) 2003 by Alan Davies
@forest
forest / rights.rb
Last active December 21, 2015 04:48
Use OO instead of basic ruby types to represent Rights
ALL_RIGHTS = [
CAN_ACCESS_RESOURCES,
CAN_ACCESS_ORGANIZATIONS,
CAN_CREATE_ORGANIZATIONS,
CAN_ACCESS_SCHOOL_EDITION
]
# ---------------------------
@forest
forest / create_koken.sh
Last active January 18, 2016 20:54 — forked from bradleyboy/create_koken.sh
Docker script for Koken
#!/bin/bash
echo ""
# Root check
if [[ "$UID" -ne 0 ]]; then
echo "!! This script requires root privileges. sudo ./create_koken.sh"
echo ""
exit
fi
@forest
forest / nullify_blank.rb
Created February 13, 2016 21:15
nullify_blank.rb
module Virtus
class Attribute
# Attribute extension which nullifies blank attributes when coercion failed
#
module NullifyBlank
# @see [Attribute#coerce]
#
# @api public
diff --git i/lib/virtus/dirty_attribute.rb w/lib/virtus/dirty_attribute.rb
index 3854a36..13c20a3 100644
--- i/lib/virtus/dirty_attribute.rb
+++ w/lib/virtus/dirty_attribute.rb
@@ -16,7 +16,7 @@ module Virtus
def _create_writer_with_dirty_tracking(name)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}=(new_regular_object)
- prev_object = #{name}
+ prev_object = instance_variable_get(:@#{name})
@forest
forest / git cheat
Created April 25, 2009 07:58
Git Cheat. #git #cheat
# create a branch
git branch <branch>
# delete a branch
git branch -d|D <branch>
# go back to master
git checkout master
# merge branch to master

Keybase proof

I hereby claim:

To claim this, I am signing this object:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello world!</h1>
<script src="script.js"></script>
@forest
forest / app.html
Created October 31, 2017 17:47 — forked from freshcutdevelopment/app.html
Aurelia Gist - RequireJS, Bootstrap, Fontawesome
<template>
<h1>${message}</h1>
</template>
Verifying my Blockstack ID is secured with the address 1QDBnDdmr45qQB1DCqm9qKriQzPvBpKSZj https://explorer.blockstack.org/address/1QDBnDdmr45qQB1DCqm9qKriQzPvBpKSZj