Skip to content

Instantly share code, notes, and snippets.


Maricris Nonato maricris-sn

View GitHub Profile
maricris-sn / database_cleaner.rb
Created November 12, 2020 13:26 — forked from jsteiner/database_cleaner.rb
Database Cleaner
View database_cleaner.rb
RSpec.configure do |config|
config.before(:suite) do
config.before(:each) do
DatabaseCleaner.strategy = :transaction
config.before(:each, js: true) do
maricris-sn / dates_to_time.rb
Created February 28, 2019 07:03
Dates To Time
View dates_to_time.rb
def dates_to_time(date_string, created_at)
if date_string[/[0-9]+/].blank?
# there aren't any numbers in it
return 0
# there's at least one number to derive date from
if date_string[/\'(\d){2}/].present?
# uses Month '14 for example
matched_year = date_string[/\'(\d){2}/]
# extrapolate the decade from when this record was created
maricris-sn / 0_reuse_code.js
Created May 20, 2016 14:31
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
maricris-sn / ftp-upload.rb
Last active September 18, 2015 04:30 — forked from taf2/ftp-upload.rb
uploading a file in ruby is hard. ftp is hard.
View ftp-upload.rb
# fireway configured with:
require 'net/ftp'
require 'stringio'
# allows us to upload files by content instead of writing to disk first
class Net::FTP
def puttextcontent(content, remotefile, &block)
f =
maricris-sn / bench_rails_memory_usage.rb
Last active August 29, 2015 14:27 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
View bench_rails_memory_usage.rb
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
View yosemite ntfs read+write.txt
Remove osxfuse if installed via homebrew:
> brew uninstall osxfuse
Install osxfuse binary and choose to install the MacFUSE compatibility layer:
Reboot (optional but recommended by osxfuse)
Install ntfs-3g via homebrew:
> brew update && brew install ntfs-3g
maricris-sn / read-split-name
Created October 28, 2014 10:07
Read a spreadsheet's fullname column; and split into first and last names
View read-split-name
# Assumes gem install 'roo' has been done
require 'roo'
# Spreadsheet filename I want to read
file_path = ENV["CONTACT_PATH"]
puts "Importing data from " + file_path
# Opening the file using roo
spreadsheet = case File.extname(file_path)
maricris-sn / do-ghost-upgrade
Last active August 29, 2015 14:05
Upgrading Ghost
View do-ghost-upgrade
# Login to your server as root
# Stop ghost service to prevent database corruption
service ghost stop
# Do some manual backups
cd /var/www
CURRENT_GHOST_TAR=/var/www/ghost-$(date +"%Y-%m-%d").tar
tar cvf $CURRENT_GHOST_TAR /var/www/ghost
View gibbon.rb
gibbon =
view ='app/views/', {instance_variable_for_templates: 5324},
campaign = gibbon.campaigns.create(
type: "regular",
options: {
list_id: 'xxxy',
from_email: '',
from_name: 'Your From',
subject: "the subject",