Skip to content

Instantly share code, notes, and snippets.

View neilmarion's full-sized avatar

Neil Marion dela Cruz neilmarion

View GitHub Profile
@neilmarion
neilmarion / Sodium monthly revenue datapoints
Created July 10, 2018 06:57
Sodium monthly revenue datapoints
[
[0] {
:text => "Less than 54,000",
:data_point_uid => "companymo1",
:uid => "lessthan51"
},
[1] {
:text => "54,001 - 268,000",
:data_point_uid => "companymo1",
:uid => "5400126801"
@neilmarion
neilmarion / tu_raw_data.json
Last active July 20, 2017 04:16
tu_raw_data
{
"raw_data":{
"member_reference_number":48192,
"user_id":"BB03000104",
"first_name":"Jacqueline",
"last_name":"del Rosario",
"civil_status":"S",
"date_of_birth":"1981-09-14T00:00:00.000+07:30",
"gender":"1",
"ac_holder_type":"HI",
@neilmarion
neilmarion / migration_update_attributes
Last active April 27, 2017 03:22
Number one rule to updating fields of database rows via Rails migration is to first check if they are existing
class UpdateAddressOfASchool < ActiveRecord::Migration
def up
['Ateneo', 'UP'].each do |name|
school = School.where(name: name).first
if school
school.update_attributes(address: "Quezon City")
end
end
end
end
module HealthCheck
class SlackNotification
attr_accessor :health_check
def initialize(health_check)
@health_check = health_check
end
def send
if beyond_threshold? && activated? && !Rails.env.development?
@neilmarion
neilmarion / gist:29c642afdcbc510876ff
Last active July 31, 2021 21:30
'ship-it' github pull-request comment bookmarklet
javascript:(function() { document.getElementById('new_comment_field').value="```
.
.'| .8
. | .8:
. | .8;: .8
. | .8;;: | .8;
. n .8;;;: | .8;;;
. M.8;;;;;: |,8;;;;;
. .,'n8;;;;;;: |8;;;;;;
. .', n;;;;;;;: M;;;;;;;;
@neilmarion
neilmarion / minibufexpl.sh
Last active August 29, 2015 14:08
minibufexpl (Mini-buffer explorer)
# https://github.com/fholgado/minibufexpl.vim
# ':edit' --> to open another file in vim and creating a new buffer
# ':new' --> to open another file in vim and creating an empty
# ':b2' --> to open a buffer with label '2'
# Commnad ':MBEbd', ':MBEbw' or ':MBEbun' could be used to delete/wipeout/unload buffers just as ':bd', ':bw' or ':bun', but the window that previously holding them will be preserved.
@neilmarion
neilmarion / sidekiq
Last active July 27, 2017 17:58
sidekiq clear counter
Sidekiq.redis {|c| c.del('stat:processed') }
and to reset failed jobs:
Sidekiq.redis {|c| c.del('stat:failed') }
bundle exec sidekiq -q high,5 default
RAILS_ENV=production bundle exec sidekiq -d -L /home/deployer/apps/collector/shared/sidekiq.log -q high,5 default
@neilmarion
neilmarion / build_gem
Created March 3, 2014 02:36
building a gem locally
gem build hola.gemspec
@neilmarion
neilmarion / requiring_gem_development.rb
Created February 28, 2014 05:41
requiring a gem during development
require 'lib/my_gem'
#http://stackoverflow.com/questions/4493114/developing-gems-and-testing
#http://stackoverflow.com/questions/4487948/how-can-i-specify-a-local-gem-in-my-gemfile
@neilmarion
neilmarion / metaprogramming.rb
Created February 19, 2014 16:10
metaprogramming
def calculate_till
self.cash_in_till = type.nil? ? cash_on_hand :
send("calculate_#{type.gsub(/-/,"_")}")
calculated_value
end