Skip to content

Instantly share code, notes, and snippets.

View srMarquinho's full-sized avatar
🎯
Focusing

Marco Araujo srMarquinho

🎯
Focusing
View GitHub Profile
Sync Atom settings
@srMarquinho
srMarquinho / vehicle_profiles.xml
Last active January 21, 2017 12:17
Navigator Mapfactor - UK United Kingdom EUROPE - Vehicle Profile - If you are here you have notice that routes time are wrong. To fix that replace ´vehicle_profiles.xml´ and choose ´Car EUROPE´ as your car profile. This will not affect default route calculation, just get a better timing (15% slower).
<?xml version="1.0" encoding="utf-8"?>
<truck_restrictions>
<selected_profile>Car EUROPE</selected_profile>
<set>
<name>Truck</name>
<vehicle_type>truck</vehicle_type>
<speed_limit>4294967295</speed_limit>
<optimization>fastest-transit</optimization>
<fuel>3</fuel>
<consumption_extra_urban>0.00000</consumption_extra_urban>
Change titlebar height in Gnome
http://unix.stackexchange.com/questions/276951/how-to-change-the-titlebar-height-in-standard-gtk-apps-and-those-with-headerbars
@srMarquinho
srMarquinho / application_controller.rb
Created February 14, 2017 09:14 — forked from scottwb/application_controller.rb
Get a list of all the filters on a given Rails 3 controller.
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end
@srMarquinho
srMarquinho / ubuntu_agnoster_install.md
Created June 17, 2017 08:00 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 14.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/marcoaraujo/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# ZSH_THEME="robbyrussell"
GET:
with JSON:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://hostname/resource
as XML:
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource
curl -H "Accept: application/xml" "http://localhost:3040/api/org.xml"
curl -H "Accept: application/xml" -H "API_KEY: fgjfgjhfj68rvuIXy5XAlpRELmHKmOZNJeot62I3rePsnFAl15Wghjgs" "http://localhost:3040/api/org"
@srMarquinho
srMarquinho / benchmark.rb
Created January 8, 2018 08:54
ruby benchmark snipet example
require 'benchmark'
n = (10**6)
Benchmark.bm(7) do |x|
x.report("1:") do
1.upto(n) do
#code
end

Here's a useful one - If you ever need to check the methods of a ruby class/module (e.g. Math or User) you can call public_methods to get the class methods and public_instance_methods to get the instance ones.

The problem with this is that you'll also get entries for everything that it inherits from too, all the way up to Object methods like is_a? and send

To get around that, because they return arrays, you can subtract the result from calling it on the base class, e.g. Math.public_methods - Module.public_methods, or User.instance_methods - ActiveRecord::Base.instance_methods

@srMarquinho
srMarquinho / my_log.rb
Created February 7, 2018 10:27
custom rails logger
class MyLog
def self.debug(message=nil)
@my_log ||= Logger.new("#{Rails.root}/log/my.log")
@my_log.debug(message) unless message.nil?
end
end