Skip to content

Instantly share code, notes, and snippets.

View klebervirgilio's full-sized avatar
🎯
Focusing

Kleber Correia klebervirgilio

🎯
Focusing
View GitHub Profile
@zenorocha
zenorocha / multiple-3rd-party-widgets.js
Last active November 14, 2022 12:18
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@avdi
avdi / selective_method_import.rb
Created January 16, 2013 06:35
Playing around with selective method import in Ruby
# Generate a module which imports a given subset of module methods
# into the including module or class.
def Methods(source_module, *method_names)
all_methods = source_module.instance_methods +
source_module.private_instance_methods
unwanted_methods = all_methods - method_names
import_module = source_module.clone
import_module.module_eval do
define_singleton_method(:to_s) do
"ImportedMethods(#{source_module}: #{method_names.join(', ')})"
@serradura
serradura / fgraph.rb
Last active December 10, 2015 00:58 — forked from anonymous/fb_public.rb
Two clients: HGet (easy way to have Net::HTTP responses supports HTTP and HTTPS) and FGraph (shortcut to do Facebook Graph API requests)
# Examples:
# client = FGraph.new("USERNAME")
#
# if you need see response details use:
# client.request # returns a Net::HTTPFound instance, with this you can see the status, headers# Examples:
# client = FGraph.new("USERNAME")
#
# client.data # returns the parsed response body
# if you need an alias to get the api data response, use:
@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

sudo ifconfig en1 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
@pmarreck
pmarreck / Ruby.sublime-build
Last active December 10, 2023 20:00
Get Sublime Text 2 (or 3) to use your RVM ruby and bundle Gemfile
# Get Sublime to use your rvm ruby... Change your ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build
# (for ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build) to this, replacing YOURUSERNAME.
# I am still looking to optimize this further... For example, avoiding hardcoding by using something like $HOME, although
# I have yet to get any form of that to work.
{
"working_dir": "${project_path}",
"cmd": [
"/Users/YOURUSERNAME/.rvm/bin/rvm-auto-ruby", "-Ilib:test", "$file"
],
@jessedearing
jessedearing / gist:2351836
Created April 10, 2012 14:44 — forked from twoism-dev/gist:1183437
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.