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 / 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 / install-postgresql-ubuntu-vagrant
Last active March 21, 2019 16:18
Install PostgreSQL 9.3 on a Ubuntu Precise VM (Vagrant)
# Add the public GPG key
wget -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Create a file with the repository address
echo deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main | sudo tee /etc/apt/sources.list.d/postgresql.list
# Remove any older postgresql installation you may have (ex:)
sudo apt-get remove postgresql-9.1 postgresql-contrib-9.1 postgresql-client-9.1
# Install the PostgreSQL
@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 / precompile.md
Last active February 27, 2023 00:16
HOW TO: Rails 4.2 add 'vendor/asset' to precompile list

To enable the precompilation of all non.js/.css assets within vendor/assets just add this to config/initializers/assets.rb:

Rails.application.config.assets.precompile << Proc.new { |path, fn| fn =~ /vendor\/assets/ && !%w(.js .css).include?(File.extname(path)) }

Be aware that this will precompile ALL non .js/.css assets that you have there, some plugins or libraries might have .txt or other files around, and those would end up into your precompiled list also.

If you need to precompile images only, you could use this:

Rails.application.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
@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 / _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 / 00steps.md
Last active January 12, 2017 03:02
Windows Development Environment
@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'