Skip to content

Instantly share code, notes, and snippets.

View hulous's full-sized avatar
🖖

Fabien Bénariac hulous

🖖
  • Lendopolis
  • Boussy Saint Antoine, France
  • 18:35 (UTC +02:00)
  • LinkedIn in/fbenariac
View GitHub Profile
@matpowel
matpowel / tableless.rb
Created July 23, 2011 10:04
An ActiveRecord emulating Tableless model which works with Rails 3.1
class Tableless < ActiveRecord::Base
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new( name.to_s, default, sql_type.to_s, null )
end
def self.columns()
@columns ||= [];
end
@ono
ono / unicorn.conf.rb
Created August 3, 2011 15:49
Workaround to avoid "adding listener failed addr=0.0.0.0:8080 (in use)" error by unicorn on FreeBSD jail host
# If you run unicorn on FreeBSD Jail, you might experience the following error
# when you send some signals such as HUP, USR2 to master process.
# adding listener failed addr=0.0.0.0:8080 (in use)
#
# This snippet gives you a workaround without specifying IP address.
# Returns true if the host is in the Jail.
def in_jail?
`sysctl security.jail.jailed` =~ /security.jail.jailed: 1/ ? true : false
end
@samqiu
samqiu / railscasts.rb
Last active December 9, 2022 03:49
Download free Railscast video
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 29, 2024 16:03
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ryansobol
ryansobol / gist:5252653
Last active November 22, 2023 11:53
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@nicolai86
nicolai86 / sync-mysql-mina.rb
Last active December 3, 2018 07:17
sync down the content of a mysql database used by a ruby on rails application using mina.
RYAML = <<-BASH
function ryaml {
ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
};
BASH
namespace :sync do
task :db do
isolate do
invoke :environment

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@hulous
hulous / Makefile
Last active January 12, 2022 20:58
My standard c and cpp makefile template
## MAKEFILE FOR C PROJECT
MYAPP = application
HEADERS = $(MYAPP).h
OBJECTS = $(MYAPP).o
default: $(MYAPP)
%.o: %.c $(HEADERS)
gcc -c $< -o $@
@trev
trev / config.yml
Created May 25, 2018 01:23
CircleCI 2.0 with parallelism & simplecov for Rails
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
defaults: &defaults
working_directory: ~/split_app
parallelism: 2
docker:
- image: circleci/ruby:2.5.0-node-browsers
@deHelden
deHelden / "torn" 1 Setup vps.md
Last active June 9, 2024 00:31
Deploy Rails 7.0.4.2 to VPS(DigitalOcean Ubuntu 20). Nginx, Puma, Capistrano3, PostgreSQL, Rbenv.

SETUP VPS

based on DigitalOcean guide

Create local project

local$ rails new appname -T -d postgresql
local$ rails g scaffold Story title:string body:text
local$ rails db:migrate