Skip to content

Instantly share code, notes, and snippets.

View danielribeiro's full-sized avatar

Daniel Ribeiro danielribeiro

View GitHub Profile
@jugyo
jugyo / gist:5727487
Last active December 18, 2015 04:39
a fix for performance improvement for the javascript_include_tag
# fix assets loading performance in 3.2.13
# see:
# * https://github.com/rails/rails/commit/687e68d88f5e1a7bb6a2d876fbbc5b8c4571d853
# * https://github.com/rails/rails/issues/9803
if Rails.env.development? && Rails.version == "3.2.13"
module Sprockets
module Helpers
module RailsHelper
class AssetPaths
def rewrite_extension(source, dir, ext)
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
(defn selector
"Creates a selection process on list-el, a HTML list element.
Parameters
in:
a channel that should produce a number for the item to
highlight, :out to remove all highlighting, and :select to
signal user selection.
list-el:
a HTML list element.
#!/bin/sh
#
# Adam Sharp
# Aug 21, 2013
#
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`.
#
# Does the inverse of `git submodule add`:
# 1) `deinit` the submodule
# 2) Remove the submodule from the index and working directory
@rmasoni
rmasoni / gist:6441804
Last active August 28, 2017 14:40
Pomodoro notifications for OS X, powered by terminal-notifier (https://github.com/alloy/terminal-notifier).
function pomodoro {
case $1 in
start )
echo 'terminal-notifier -title "🍅 Pomodoro Done" -message "Starting short break…"' | at + 25 minutes &> /dev/null
;;
break )
echo 'terminal-notifier -title "⌛ Short Break Done" -message "Start your next Pomodoro."' | at + 5 minutes &> /dev/null
;;
esac
scala> val x = null.asInstanceOf[Int]
x: Int = 0
scala> Option(x)
res1: Option[Int] = Some(0)
scala> Option(null.asInstanceOf[Int])
res2: Option[Int] = None
@andrewroycarter
andrewroycarter / Cocoapods Environment.md
Last active August 17, 2023 10:44
Directions on installing chruby, ruby, ruby-build, and bundler.

Setting up a good cocoapods environment

Before you start

Make sure that you have the latest version of Xcode installed from the Mac App Store, and that you have the command line tools installed. To install the command line tools, open Xcode, click Xcode->Preferences->Downloads->Command Line Tools

Install brew if needed.

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

function draw(ctx, f, width, height) {
var y;
var ch = height/2;
var cw = width/2;
ctx.beginPath();
ctx.moveTo(0, ch-f(-width));
for (var x=-width+1; x<width; x++) {
y = ch-f(x);
ctx.lineTo(x+cw, y);
}
@chrisn
chrisn / popen3_test
Last active March 2, 2023 08:48
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
#
def all_eof(files)
files.find { |f| !f.eof }.nil?
end
@iconara
iconara / profile_json_to_dot.rb
Last active February 2, 2016 21:39
Convert a JRuby JSON profile to a call tree graph (see second file for usage).
require 'json'
require 'set'
class ProfileConverter
def initialize(profile, io=$stdout, time_threshold=0.01)
@profile = profile
@io = io
@time_threshold = time_threshold
end