Skip to content

Instantly share code, notes, and snippets.

View equivalent's full-sized avatar
:octocat:
I'm IDDQD + IDKFA for Ruby on Rails

Tomas Valent equivalent

:octocat:
I'm IDDQD + IDKFA for Ruby on Rails
View GitHub Profile
@redrick
redrick / gem install pg
Created November 1, 2011 08:15
unable to install pg gem - *** extconf.rb failed ***
(Operating system is Fedora 2.6.40.6-0.fc15.i686)
Hi there quiet recently I had a big problem with this guy - gem install pg
It threw me :
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
@taylor
taylor / aes_test.rb
Created February 22, 2012 06:24
Ruby AES encryption test with lib openssl
#!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems'
begin
require 'bundler/setup'
rescue LoadError
end
require 'digest/sha1'
require 'openssl'
@yortz
yortz / carrierwave.rb
Created November 27, 2010 16:49
image_uploader.rb
#config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.production? or Rails.env.development?
config.storage :cloud_files
config.cloud_files_username = "your_username"
config.cloud_files_api_key = "your_key"
config.cloud_files_container = "test"
config.cloud_files_cdn_host = "c0012345.cdnn.cloudfiles.rackspacecloud.com"
def store_dir
@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
@aaronzirbes
aaronzirbes / gist:3239033
Created August 2, 2012 17:43
brew doctor and libmacfuse/libosxfuse
If you see...
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libmacfuse_i32.2.dylib /usr/local/lib/libmacfuse_i64.2.dylib /usr/local/lib/libosxfuse_i32.2.dylib /usr/local/lib/libosxfuse_i64.2.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
@Austio
Austio / NGINX on Ruby on Rails with Unicorn and GZIP assets
Last active September 3, 2018 19:22
Configure NGINX for SSL using unicorn and gzip assets optimizations
1. Open a command prompt and navigate to /etc/nginx/ssl
2. Issue "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"
3. Get your certificate issued - Go to your certificate authority and give them the CSR (server.csr)
4. Copy your new crt (that the certificate authority issued) to the /etc/nginx/ssl and give it read priveledges
5. Reconfigure your nginx.conf, here is mine. The first part redirects 80 to 443, the second part listens to 443 and is optimized to return Ruby on Rails application requests using gzip and unicorn.
@amirrajan
amirrajan / subspace.rb
Created February 27, 2019 21:50
Initial work for a subspace clone written on top of a game engine I'm working out that hasn't been released yet.
class Game
attr_accessor :_
def default_ship x, y, heading
_.new(:ship) do |s|
s.x = x
s.y = y
s.dy = 0
s.dx = 0
s.heading = heading
@phoebebright
phoebebright / index.html
Created July 18, 2018 10:14
Materialize AutoComplete with id
<div class="row">
<div class="col s12">
<div class="row">
<div class="input-field col s13">
<i class="material-icons prefix">textsms</i>
<input type="text" id="autocomplete" class="autocomplete" >
<label for="autocomplete">Autocomplete</label>
</div>
</div>
</div>
@cybersamx
cybersamx / capybara_cheat_sheet.rb
Last active June 26, 2022 08:32
Capybara (visit/page) cheat sheet
# Navigation
visit('/resources')
visit(resource_path(resource))
# Clicking buttons and hyperlinks
click_button('Submit Button')
click_link('Link Text')
click_link('Link id')
click('Link or button')
@ryanb
ryanb / issues_with_modules.md
Created November 29, 2012 22:38
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base