Skip to content

Instantly share code, notes, and snippets.

Jose C Fernandez Joseworks

Block or report user

Report or block Joseworks

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
@Joseworks
Joseworks / pg_stat_statements
Created May 11, 2017 — forked from troyk/pg_stat_statements
enable postgres pg_stat_statements
View pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
@Joseworks
Joseworks / casting_types.rb
Created May 11, 2017 — forked from otobrglez/casting_types.rb
unknown OID 705: failed to recognize type of '<field>'. It will be treated as String.
View casting_types.rb
#!/usr/bin/env ruby
# If you get "unknown OID 705: failed to recognize type of '<field>'. It will be treated as String."
# it probably means that type of column could not be identified when retriving records
# Example
User.where("'something' as something")
# Will results in unknown OID. However doing this:
@Joseworks
Joseworks / gist:f48ebd5a10bf5eb39386a601cd84fa39
Created May 10, 2017 — forked from giannisp/gist:b53a76047b07751ed3ade3c1db1d2c51
Upgrade PostgreSQL 9.5.5 to 9.6.1 using Homebrew (macOS)
View gist:f48ebd5a10bf5eb39386a601cd84fa39
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work.
The error was something like "database files are incompatible with server".
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default
brew unlink postgresql
brew install postgresql95
brew unlink postgresql95
brew link postgresql
@Joseworks
Joseworks / routes.md
Created Apr 17, 2017 — forked from dideler/routes.md
Rails Routes
View routes.md

A summary of the Rails Guides on Routes, plus other tips.

The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.

Examples

# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'
@Joseworks
Joseworks / gist:e37b8cef884105da2933c78d1c45fccd
Created Apr 14, 2017 — forked from vcabansag/gist:7308a3d79ca57ede4e73
Adding HTTP Authentication to a Middleman app using Heroku environment variables
View gist:e37b8cef884105da2933c78d1c45fccd
require "rubygems"
require "rack"
require "middleman/rack"
require "rack/contrib/try_static"
protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password|
[username, password] == [ENV['HTTP_USERNAME'], ENV['HTTP_PASSWORD']]
# Enable proper HEAD responses
use Rack::Head
@Joseworks
Joseworks / config.ru
Created Apr 14, 2017 — forked from pmkhoa/config.ru
Middleman Authentication via Rack
View config.ru
require 'rubygems'
require 'middleman/rack'
protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password|
[username, password] == ['theuser', 'thepassword']
end
run protected_middleman
@Joseworks
Joseworks / progress_bar.rb
Created Feb 20, 2017 — forked from kuntoaji/progress_bar.rb
Simple progress bar script without Gem using Ruby.
View progress_bar.rb
#!/usr/bin/env ruby
progress = 'Progress ['
1000.times do |i|
# i is number from 0-999
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0
@Joseworks
Joseworks / progress_bar.rb
Created Feb 20, 2017 — forked from kuntoaji/progress_bar.rb
Simple progress bar script without Gem using Ruby.
View progress_bar.rb
#!/usr/bin/env ruby
progress = 'Progress ['
1000.times do |i|
# i is number from 0-999
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0
@Joseworks
Joseworks / web-fonts-asset-pipeline.md
Created Feb 10, 2017 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline
View web-fonts-asset-pipeline.md

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@Joseworks
Joseworks / .gitconfig
Created Jan 25, 2017 — forked from robmiller/.gitconfig
Some useful Git aliases that I use every day
View .gitconfig
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
You can’t perform that action at this time.