Skip to content

Instantly share code, notes, and snippets.

Roberto Ostinelli ostinelli

Block or report user

Report or block ostinelli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ostinelli
ostinelli / intellij
Last active Nov 7, 2019
[Intellij] Run mix tests in open terminal
View intellij
Program: /Users/roberto/workspace/intellij_run_cmd
Arguments: "mix test $FilePathRelativeToProjectRoot$:$SelectionEndLine$"
@ostinelli
ostinelli / biggest_file_by_ext.rb
Last active Sep 5, 2019
List biggest file size by extension on a directory.
View biggest_file_by_ext.rb
require 'find'
biggest_file_by_ext = {}
Find.find('.') do |path|
next if File.directory?(path)
# get file info
ext = File.extname(path)
next unless ext.length > 0
# get file size
size = File.size(path)
@ostinelli
ostinelli / php.sh
Created Apr 12, 2019
Start local php server on OSX
View php.sh
php -S 127.0.0.1:8080
@ostinelli
ostinelli / simple_api_client.rb
Last active Dec 13, 2018
Simple JSON API Ruby Client
View simple_api_client.rb
require 'net/http'
require 'json'
class Client
def call(method, url, path=nil, headers={}, body=nil, timeout=60)
net_class = Object.const_get("Net::HTTP::#{constantize(method)}")
uri = URI("#{url}#{path}")
View Preferences.Sublime-settings
{
"ensure_newline_at_eof_on_save": true,
"font_size": 12.0,
"trim_trailing_white_space_on_save": true
}
@ostinelli
ostinelli / aws_acl_updater.rb
Last active Jan 11, 2017
Batch update ACL permissions on AWS.
View aws_acl_updater.rb
# add AWS credentials to ENV variables or modify the script to pass in credentials
require 'thread'
require 'aws-sdk'
# settings
region = 'my-region'
bucket = 'my-bucket'
prefix = 'my-prefix'
acl = "private"
parallel = 25
@ostinelli
ostinelli / reloader.rb
Last active Jul 1, 2018
Reload an initializer file on every request in Rails.
View reloader.rb
# add this into application.rb
initializer_file = Rails.root.join('config', 'initializers', 'my_initializer.rb')
reloader = ActiveSupport::FileUpdateChecker.new([initializer_file]) do
load initializer_file
end
ActiveSupport::Reloader.to_prepare do
reloader.execute
end
@ostinelli
ostinelli / activerecord_callback.md
Last active Jul 6, 2018
ActiveRecord callback when connection is made
View activerecord_callback.md

The ConnectionAdapter defines two callbacks :checkout (connect) and :checkin (disconnect).

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.set_callback :checkout, :after do
  raw_connection
end

Source.

@ostinelli
ostinelli / simulator.sh
Created Mar 22, 2016
Open iOS simulator directly from console
View simulator.sh
alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'
@ostinelli
ostinelli / homebrew.sh
Created Mar 19, 2016
Homebrew install specific version
View homebrew.sh
brew install https://raw.githubusercontent.com/Homebrew/homebrew/7e8d2664f782c3ac6a2ebb21393c9f047e6a1134/Library/Formula/erlang.rb
You can’t perform that action at this time.