Skip to content

Instantly share code, notes, and snippets.

@kyanny
kyanny / gist:1668822
Created January 24, 2012 08:22
bashrc prompt git && rbenv
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
source ~/.rbenv/completions/rbenv.bash
# prompt with ruby version
# rbenv version | sed -e 's/ .*//'
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
@brianr
brianr / gist:319cd1a3b6d3d4bf2980
Last active October 1, 2015 15:21
rollbar instrumentation for angular js exception handler
angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
return function(exception, cause) {
Rollbar.error(exception, {cause: cause});
throw exception;
};
});
@fguillen
fguillen / my_wrapper_creator.rb
Last active May 19, 2019 05:55
Providing an `around_action` like functionality in arbitrary Ruby classes
module MyWrapperCreator
def my_method_wrapper(method_name)
original_method = instance_method(method_name)
define_method(method_name) do |*args, &block|
puts "wrapper :: INI"
result = original_method.bind(self).call(*args, &block)
puts "wrapper :: END"
result
@JamesMcMahon
JamesMcMahon / lerp.rb
Created May 4, 2016 19:43
Lerp code in Ruby, just for reference
def lerp(start, stop, step)
(stop * step) + (start * (1.0 - step))
end
@morimori
morimori / 1.9.3-p0.log
Created November 1, 2011 07:29
ruby Digest::* benchmark
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
Rehearsal ------------------------------------------
MD5 1.010000 0.000000 1.010000 ( 1.026340)
SHA1 1.710000 0.000000 1.710000 ( 1.724464)
SHA2 3.780000 0.000000 3.780000 ( 3.824757)
SHA256 3.460000 0.010000 3.470000 ( 3.498111)
--------------------------------- total: 9.970000sec
user system total real
MD5 1.020000 0.000000 1.020000 ( 1.025751)
@whity-82
whity-82 / gist:5403900
Last active December 2, 2023 02:18
Sample of drawing text with Gosu & Ruby.
require 'gosu'
class GameWindow < Gosu::Window
def initialize
super 640, 480, false
self.caption = "Gosu Tutorial Game"
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
end
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@lttr
lttr / vue3-docs-to-eink.sh
Created January 18, 2024 13:18
I wanted to read the VueJS docs on my eink tablet. HTML seems to work even better then EPUB in Boox NeoReader app.
#!/usr/bin/env bash
set -e
TEMPORARY="vue-docs.md"
GUIDE_PATH="./src/guide/"
OUTPUT_EPUB="vue-docs.epub"
OUTPUT_HTML="vue-docs.html"
git clone --depth=1 https://github.com/vuejs/docs
@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@Oxeren
Oxeren / MySingletonSO.cs
Last active February 15, 2024 04:57
Auto singleton Unity ScriptableObject. Derive your class from this class (and use your class as the generic type), create an instance in the Resources folder (name of the instance must be the same as the name of your class). Then you will be able to access the singleton via static Instance property without having to add boilerplate code.
// Example Scriptable Object. Instance must be placed in Resources folder and have the same name as the class, type of generic parameter must be your class.
using UnityEngine;
[CreateAssetMenu(fileName = "MySingletonSO")]
public class MySingletonSO : SingletonScriptableObject<MySingletonSO>
{
// Here goes your data. This class can be called by the static Instance property, which will automatically locate the instance in the Resources folder.
}