Skip to content

Instantly share code, notes, and snippets.

View LucasArruda's full-sized avatar
🎯
Focusing

Lucas Arruda LucasArruda

🎯
Focusing
View GitHub Profile
@sivers
sivers / audiobook.rb
Created June 25, 2019 20:32
Create my audiobook, 88 chapters with 9 ingredients to each chapter, using Ruby + sox
#!/usr/bin/env ruby
# if limiting to one chapter, ./audiobook.rb 05
LIMIT = (ARGV[0] =~ /\A[0-9][0-9]\Z/) ? ARGV[0] : false
BASE = Dir.pwd + '/'
NUMS = BASE + 'ChapterNums/'
DRUM = BASE + 'DrumFills/'
GUIT = BASE + 'GuitarChords/'
URLS = BASE + 'URLs/'
@shime
shime / _README.md
Last active March 15, 2021 19:26
comparing dates and times in RSpec

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
#!/usr/bin/env ruby
# encoding: utf-8
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
@capripot
capripot / i18n.rb
Created March 24, 2015 19:32
Show Rails i18n default scope
module I18n
module Backend
class Simple
module Implementation
alias_method :lookup_orig, :lookup
# Give ability to check I18n looked up keys in lazy mode by setting env var I18N_DEBUG to true
#
def lookup(locale, key, scope = [], options = {})
puts "I18N keys: #{I18n.normalize_keys(locale, key, scope, options[:separator])}" if ENV['I18N_DEBUG']
@drbh
drbh / checkIsBrave.js
Created January 30, 2019 20:19
Reliably detect Brave Browser with native JS
// helper to find Brave in User Agent string
function isBraveAgent(userAgentResponse) {
var isBraveIndex = ~userAgentResponse.indexOf('Brave')
if (isBraveIndex < 0) {
return true
}
return false
}
// Function from Javarome

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
  • NBC
@vishalzambre
vishalzambre / curl.sh
Last active October 2, 2021 02:30
Using devise gem sign_in & sign_out API's with sessions
#login
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"email":"<email>","password":"<passwd>"}}' http://localhost:3000/api/v1/sign_in.json
#logout
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X DELETE http://localhost:3000/api/v1/sign_out.json?auth_token=<token>
@nileshtrivedi
nileshtrivedi / hash_builder.rb
Created November 24, 2011 17:49 — forked from brentd/gist:360506
HashBuilder allows you to build a Hash in Ruby similar to Builder with some enhancements
# Allows you to build a Hash in a fashion very similar to Builder. Example:
# Fork of https://gist.github.com/360506 by BrentD with some enhancements
#
# HashBuilder.build! do |h|
# h.name "Nilesh"
# h.skill "Ruby"
# h.skill "Rails" # multiple calls of the same method will collect the values in an array
# h.location "Udaipur, India" do # If a block is given, first argument will be set as value for :name
# h.location do
# h.longitude 24.57
@jwo
jwo / secret_controller.rb
Created November 5, 2013 17:57
Devise testing controllers - minitest / rails4
class SecretController < ApplicationController
before_filter :authenticate_user!
def show
end
end
@aderowbotham
aderowbotham / django_ami.md
Created June 7, 2012 14:19
Django stack setup on EC2 AMI

Django Stack

Overview

This is a set of instructions to setup a Django Nginx Gunicorn MySQL/Postgres stack on a single Amazon EC2 instance.

Server - AWS