Skip to content

Instantly share code, notes, and snippets.

View rthbound's full-sized avatar

Ryan T. Hosford rthbound

View GitHub Profile
@ventsislaf
ventsislaf / phoenix_heroku_reset_db.md
Last active May 18, 2023 14:14
Reset database on Heroku running Phoenix app

Note: Don't do this on a production evniroment!

Get the heroku database name:

heroku pg:info

Name can be found in the reponse from the command above. For example: Add-on: soaring-newly-1337.

@0x0dea
0x0dea / process_gsub.rb
Created April 26, 2015 23:08
Process.gsub lets you search and replace within your process's live memory!
def Process.gsub pat, sub
mem = File.open('/proc/self/mem', 'r+')
maps = File.open('/proc/self/maps')
maps.each do |map|
from, to, perms, offset = map.scan(/(\h+)-(\h+) (\S+) (\h+)/)[0]
if perms['rw']
from, to = [from, to].map { |addr| addr.hex + offset.hex }
data = mem.tap { |m| m.seek from }.read(to - from) rescue next
@patrickhammond
patrickhammond / android_instructions.md
Last active September 9, 2024 09:21
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

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

@mattsmith
mattsmith / dynamic_stylesheet.rb
Created October 11, 2013 06:31
Renders a scss stylesheet with erb using Tilt templates.
class DynamicStylesheet
# logical_path = 'app/assets/stylesheets/custom.css.scss.erb'
def render(logical_path, data={})
path = Rails.root.join(logical_path)
context = env.context_class.new(env, logical_path, Pathname.new(path))
# TODO Change to Tilt.templates_for(file) in Tilt 2.x
templates = [Tilt::ERBTemplate, Sass::Rails::ScssTemplate]
@ronanrodrigo
ronanrodrigo / Gemfile
Created June 10, 2013 04:10
Eventos recorrentes no ruby on rails. A criação recorrência de eventos em qualquer ambiente, requer uma avançada lógica de regras. Entre as dificuldades está os Time Zones, UTC e o querido mês de Fevereiro. Pra facilitar tudo isso, existe uma gem chamada Ice Cube. Que irá ajudar a criar uma regra de repetição para um evento. Fonte: http://seejoh…
gem 'ice_cube'
@rmetzler
rmetzler / gist:2947828
Created June 18, 2012 10:43
find all non UTF-8 encoded files
find . -type f | xargs -I {} bash -c "iconv -f utf-8 -t utf-16 {} &>/dev/null || echo {}" > utf8_fail
@thbar
thbar / README.md
Created September 15, 2011 13:25
A quick benchmark for ice_cube

Quick benchmark to see how ice_cube behaves in the far future. It seems that the cost is linearly increasing.

Results at: http://bit.ly/pjsQH1

(note: second version is without the time parse in the loop)

@seejohnrun
seejohnrun / 9_to_5.rb
Created May 24, 2011 20:36
ice_cube 9-5
s = IceCube::Schedule.new(Time.now, :duration => 3600 * 7)
s.add_recurrence_rule IceCube::Rule.daily.day(:monday, :tuesday, :wednesday, :thursday, :friday).hour_of_day(9)
s.occurring_at?(Time.new(2011, 5, 30, 10, 0, 0)) # true, monday at 10am
s.occurring_at?(Time.new(2011, 5, 29, 10, 0, 0)) # false, sunday at 10am
s.occurring_at?(Time.new(2011, 5, 30, 8, 0, 0)) # false, monday at 8am