Skip to content

Instantly share code, notes, and snippets.

View vhsalazar's full-sized avatar

Victor Salazar vhsalazar

  • Sydney, Australia
View GitHub Profile
@vhsalazar
vhsalazar / rat_boy.rb
Last active August 5, 2022 02:58
flights.rb
require 'date'
require 'active_support/core_ext/object/to_query'
require "active_support/core_ext/numeric/time"
require 'launchy'
flights = [
{from: 'SYD', to: 'LAX', date: Date.new(2022,12,9), delta: (0..2)},
{from: 'LAX', to: 'NAN', date: Date.new(2023,02,2), delta: (0..2)},
{from: 'NAN', to: 'SYD', date: Date.new(2023,02,7), delta: (0..2)}
]
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 33 columns, instead of 20 in line 8.
school,sex,age,address,famsize,Pstatus,Medu,Fedu,Mjob,Fjob,reason,guardian,traveltime,studytime,failures,schoolsup,famsup,paid,activities,nursery,higher,internet,romantic,famrel,freetime,goout,Dalc,Walc,health,absences,G1,G2,G3
GP,F,18,U,GT3,A,4,4,at_home,teacher,course,mother,2,2,0,yes,no,no,no,yes,yes,no,no,4,3,4,1,1,3,6,5,6,6
GP,F,17,U,GT3,T,1,1,at_home,other,course,father,1,2,0,no,yes,no,no,no,yes,yes,no,5,3,3,1,1,3,4,5,5,6
GP,F,15,U,LE3,T,1,1,at_home,other,other,mother,1,2,3,yes,no,yes,no,yes,yes,yes,no,4,3,2,2,3,3,10,7,8,10
GP,F,15,U,GT3,T,4,2,health,services,home,mother,1,3,0,no,yes,yes,yes,yes,yes,yes,yes,3,2,2,1,1,5,2,15,14,15
GP,F,16,U,GT3,T,3,3,other,other,home,father,1,2,0,no,yes,yes,no,yes,yes,no,no,4,3,2,1,2,5,4,6,10,10
GP,M,16,U,LE3,T,4,3,services,other,reputation,mother,1,2,0,no,yes,yes,yes,yes,yes,yes,no,5,4,2,1,2,5,10,15,15,15
GP,M,16,U,LE3,T,2,2,other,other,home,mother,1,2,0,no,no,no,no,yes,yes,yes,no,4,4,4,1,1,3,0,12,12,11
GP,F,17,U,GT3,A,4,4,other,teacher,home,mother,2,2,0,yes,yes,no,no,y
### Keybase proof
I hereby claim:
* I am vhsalazar on github.
* I am vhsalazar (https://keybase.io/vhsalazar) on keybase.
* I have a public key ASAjCDnM2xie4DT3bxKFu3xiFG4KYJviSF9JVO-NrsLQHAo
To claim this, I am signing this object:
@vhsalazar
vhsalazar / gist:20fbe1f64c6d615594c7
Created August 29, 2014 17:32
Nginx config - Rails
upstream backend {
server 127.0.0.1:9000;
}
log_format default_log '$host $remote_addr [$time_local] "$request" $status $request_length "$http_referer" "$http_user_agent" $request_time';
server {
listen 80;
server_name _; # all accept
access_log /var/log/nginx/access.log default_log;

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@vhsalazar
vhsalazar / webserver.rb
Created December 26, 2013 13:19
Simple webrick server without any caching
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
end