Skip to content

Instantly share code, notes, and snippets.

View maricris-sn's full-sized avatar
😺

Maricris Nonato maricris-sn

😺
View GitHub Profile
@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@DRBragg
DRBragg / file_uploader.rb
Last active September 27, 2023 06:46
PDF Previews with carrierwave
class ItemUploader < CarrierWave::Uploader::Base
require 'carrierwave/orm/activerecord'
include CarrierWave::RMagick
attr_reader :geometry
# Create thumbnail for images and PDFs
version :thumb, :if => :thumbable? do
process :resize_to_fit => [240, 240], :if => :image?
process :pdf_preview => [240, 240], :if => :pdf?
@maxivak
maxivak / readme.md
Last active March 25, 2023 01:56
sitemap.xml for Rails 4 application

Generate sitemap.xml in Rails app

This post shows how to make sitemap.xml for your web site. The sitemap will be accessible by URL http://mysite.com/sitemap.xml

Routes

Myrails::Application.routes.draw do
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active October 6, 2022 12:47
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`.
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(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@bjorgvino
bjorgvino / yosemite ntfs read+write.txt
Last active December 2, 2021 03:58
osxfuse + ntfs-3g + Yosemite = NTFS R/W
Remove osxfuse if installed via homebrew:
> brew uninstall osxfuse
Install osxfuse binary and choose to install the MacFUSE compatibility layer:
http://sourceforge.net/projects/osxfuse/files/latest/download?source=files
Reboot (optional but recommended by osxfuse)
Install ntfs-3g via homebrew:
> brew update && brew install ntfs-3g
@taf2
taf2 / ftp-upload.rb
Last active November 16, 2016 20:32
uploading a file in ruby is hard. ftp is hard.
# fireway configured with: http://major.io/2007/07/01/active-ftp-connections-through-iptables/
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 = StringIO.new(content)
begin
@kristopherjohnson
kristopherjohnson / git-flow-cheatsheet.md
Last active October 3, 2022 11:19
git-flow Snippets
@jsteiner
jsteiner / database_cleaner.rb
Created January 10, 2014 20:31
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
@d3noob
d3noob / .block
Last active July 11, 2023 19:59
Simple vertical d3.js tree diagram
license: mit