Skip to content

Instantly share code, notes, and snippets.

View ronzalo's full-sized avatar
🎯
coding...

Gonzalo Moreno ronzalo

🎯
coding...
View GitHub Profile
@briankung
briankung / docker-pry-rails.md
Last active December 12, 2023 10:40
Using pry-rails with Docker

First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

@remarkablemark
remarkablemark / Dockerfile
Last active April 24, 2024 13:40
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@airblade
airblade / copy_attachments.rb
Created November 10, 2015 11:01
Copies S3-stored Paperclip attachments from one AR model to another
# lib/paperclip/copy_attachments.rb
# Copies S3-stored Paperclip attachments from one AR model to another.
#
# This module should be mixed into the target AR model.
if Gem::Version.new(::AWS::VERSION) >= Gem::Version.new(2)
raise NotImplementedError, 'coded for aws-sdk v1'
end
@gonzalo-bulnes
gonzalo-bulnes / safe_merge.sh
Last active August 16, 2022 15:44
Some merging rules to make collaboration easier through repository order. Think of rebasing as updating the context in which you write your feature, see also: https://gonzalo-bulnes.github.io/blog/gardening_with_git/context-from-scratch.html
# safe merge
#
# merge the branch XXXXXXXX-add-example-feature into master
# make sure the feature is properly tested and
# doesn't break anything in its original context
git checkout XXXXXXXX-add-example-feature
rake # the test suite MUST NOT raise any error
# make sure your local copy of master is up-to-date
@ecleel
ecleel / diff.rb
Created June 5, 2014 08:11
SequenceMatcher class in ruby. credit to testunit folks.
# port of Python's difflib.
#
# Copyright (c) 2001-2008 Python Software Foundation; All Rights Reserved
# Copyright (c) 2008-2011 Kouhei Sutou; All Rights Reserved
#
# It is free software, and is distributed under the Ruby
# license and/or the PSF license. See the COPYING file and
# PSFL file.
# Carry this code from testunit/testunit project.
@tadast
tadast / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@sinfante
sinfante / migration.rb
Created December 4, 2013 20:50
Ruby on Rails seed for regions and counties ("comunas") of Chile with the required migrations.
class Migration < ActiveRecord::Migration
def change
create_table :countries do |t|
t.string :name
t.timestamps
end
create_table :regions do |t|
t.string :short_name
@sunny
sunny / paperclip_has_destroyable_file.rb
Created October 25, 2012 17:03
Rails Initializer to add destroyable attachments with Paperclip
# encoding: UTF-8
class ActiveRecord::Base
# Class method to add destroyable paperclip attachments.
#
# Example:
# has_attached_file :image
# has_destroyable_file :image
# attr_accessible :image_delete
#
@dinnouti
dinnouti / _form.html.erb
Created October 15, 2012 22:59
Typeahead / Autocomplete with Twitter Bootstrap, Rails, simple_form
<%= f.input :nome, :collection => get_schools_name, :include_blank => false, :input_html => {:rel => 'autocomplete', :data_default => @school.nome} %>
@Daniel15
Daniel15 / 1_Twitter autoresponder bot.md
Last active December 6, 2021 20:37
Twitter autoresponder bot

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

Questions? See my blog post - http://dan.cx/blog/2011/06/twitter-autoreply-bot-dbznappa

Modified 2013-06-13 - Twitter API 1.0 discontinued, modified to use Twitter API 1.1