Skip to content

Instantly share code, notes, and snippets.

View mrbongiolo's full-sized avatar
🚀
Just shiplling

Ralf Schmitz Bongiolo mrbongiolo

🚀
Just shiplling
View GitHub Profile
@mrbongiolo
mrbongiolo / sublime_text_3_use_regex_on_find.md
Last active August 29, 2015 14:14
Using REGEX to find and replace text on Sublime Text 3

Example 'find what' regex: url\(['"]*(?<url>[^<%|^'<%|^"<%].*?[^'"])['"]*\)
Example 'replace with' regex: url("<%= asset_path '$+{url}' %>")

I used this regex to find url('path/my_image_file.png') and convert it to url("<%= asset_path 'path/my_image_file.png' %>").

Tips:

(?<named>expression) is a named subexpression, and it can be accessed on the 'replace with' field using: $+{named}.

Sublime uses the Perl REGEX engine.

@mrbongiolo
mrbongiolo / _tab_relatives.html.erb
Last active August 29, 2015 14:18
React and Rails
<!-- app/views/associates/edit/_tab_relatives.html.erb -->
<!-- The render method is used to get the same data for the resourcesCollection
as I would get if I did a GET request later on to associates/relatives path
TODO: use a Decorator or something like it to fetch this data without the need
to render a view. -->
<%= react_component('RelativesPage', {
resourcesCollectionJSONInitialData: render(
template: 'relatives/index',
formats: :json,
locals: { :@relatives => @associate_relatives }),
@mrbongiolo
mrbongiolo / autoexec.cfg
Last active September 30, 2015 13:21
Dota 2 autoexec.cfg
// This file is located at: steam_install_folder/SteamApps/common/dota 2 beta/dota/cfg/
dota_camera_accelerate 49
dota_camera_speed 3900
dota_force_right_click_attack 1
dota_minimap_hero_size 600
dota_hud_health_bars 3
dota_health_per_vertical_marker 250
con_enable 1
dota_ability_quick_cast 1
dota_player_multipler_orders 1
@mrbongiolo
mrbongiolo / decorator.rb
Created October 8, 2015 20:58
A Decorator module for Trailblazer, basically it's just a copy of the Representer module, but it only adds the rendering methods.
# Including this will change the way the Operation renders the contract
#
# TODO: so far, we only support JSON, but it's two lines to change to support any kind of format.
module Trailblazer::Operation::Decorator
def self.included(base)
base.inheritable_attr :_decorator_class
base.extend ClassMethods
end
module ClassMethods
@mrbongiolo
mrbongiolo / _decorator_style.md
Last active October 12, 2015 22:11
Trailblazer Operation usecase using a Decorator instead of the Representer.
@mrbongiolo
mrbongiolo / Gemfile
Created October 22, 2015 17:33
Rack + Lotus Router + Trailblazer
source 'https://rubygems.org'
ruby "2.2.3"
gem 'rack'
gem 'lotus-router'
gem 'lotus-validations'
gem 'trailblazer'
gem 'roar'
gem 'multi_json'
@mrbongiolo
mrbongiolo / roda.rb
Created May 24, 2016 02:35
Super basic example of Roda + Trailblazer
# This app is an API only, that's why we set :json as response and as params.
# This is the Roda Router.
# This app used roda + hanami model + TRB;
# Those methods `present Ami::V1::Customer::Collection` are calls to the app Operations
# #present and #run are helper methods added to handle the response of an Operation.
# Basically when I `run` and operation and it is successful I'll just call Operation#decorated hash and transform it into JSON;
# If the operation failed then I'll create a json response with status: :unprocessable_entity and call the Operation#error.messages and add it to the json response.
module Ami
module V1
class Routes < Roda
@mrbongiolo
mrbongiolo / manageable_time_range.rb
Last active June 17, 2016 18:23
A horrendous approach to "manage" Time Ranges in ruby.
class ManageableTimeRange < Range
def <=>(other)
leg_min(other)
end
def leg_min(other)
return -1 if self.min < other.min
return 0 if self.min == other.min
return 1
@mrbongiolo
mrbongiolo / fql_query_page_photos.fql
Last active June 22, 2016 19:44
Query for FQL to get all photos from a Facebook Page albums and all photos tagged with that Facebook Page
# Formatted for readability
SELECT src, src_height, src_width, src_small, src_small_height, src_small_width
FROM photo
WHERE pid IN (SELECT pid
FROM photo_tag
WHERE subject='243117879034102' )
OR
pid IN (SELECT pid
FROM photo
WHERE aid IN (SELECT aid
@mrbongiolo
mrbongiolo / LSI_how_to_build.md
Last active September 14, 2016 16:15
HOW TO build linux-steam-instegration on ElementaryOS Loki

for those noobs like me

git clone git@github.com:solus-project/linux-steam-integration.git
cd linux-steam-integration
./autogen.sh --with-real-steam-binary=/usr/games/steam --enable-frontend
sudo make
sudo checkinstall --pkgname=linux-steam-integration --pkgversion=0.2 --provides=linux-steam-integration