Skip to content

Instantly share code, notes, and snippets.

View rokumatsumoto's full-sized avatar
:shipit:
shipping bits

Samet Gunaydin rokumatsumoto

:shipit:
shipping bits
View GitHub Profile
@swanson
swanson / .irbrc
Last active March 3, 2024 17:14
.irbrc color coding Rails console by environment
# Add color coding based on Rails environment for safety
if defined? Rails
banner = if Rails.env.production?
"\e[41;97;1m #{Rails.env} \e[0m "
else
"\e[42;97;1m #{Rails.env} \e[0m "
end
# Build a custom prompt
@entcheva
entcheva / REPRODUCTION_SCRIPT.rb
Created March 20, 2020 19:51
Reproduction script for Issue #1372
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "factory_bot", "~> 5.0"
gem "activerecord"
gem "sqlite3"
end
@gamecreature
gamecreature / pundit_extension_helper.rb
Created May 21, 2019 10:23
Pundit Helper to invoke different resolve method in Pundit scope class
module PunditExtensionHelper
# this method is the same as the pundit_scope method
# the difference is, it doesn't invoke the resolve method
def policy_scoper(scope_in, method = :resolve)
scope = scope_in.is_a?(Array) ? scope_in.last : scope_in
policy_scope_class = Pundit::PolicyFinder.new(scope).scope!
return unless policy_scope_class
begin
@ServerlessBot
ServerlessBot / IAMCredentials.json
Last active December 20, 2023 16:50
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@janko
janko / Gemfile
Created May 31, 2018 19:57
Memory profiling of http.rb and other popular Ruby HTTP client libraries
source "https://rubygems.org"
gem "roda"
gem "http", "~> 3.3"
gem "rest-client"
gem "httparty"
@maxivak
maxivak / webpacker_rails.md
Last active April 13, 2023 18:46
Webpack, Yarn, Npm in Rails
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active August 9, 2022 07:38
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@danielalvarenga
danielalvarenga / puma.rb
Last active October 16, 2021 20:08
Puma config for rails 5 api
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
# More: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#threads
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
@joshtab
joshtab / sidekiq.config
Last active October 28, 2019 14:52 — forked from ssaunier/sidekiq.config
Running Sidekiq on AWS Elastic Beanstalk (Put that file in `.ebextensions` folder)
# Sidekiq interaction and startup script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
owner: root
group: root
@AntoniusGolly
AntoniusGolly / index.js
Created March 18, 2018 17:17
Sample Node.js script for resizing images with the Sharp library
'use strict';
const AWS = require('aws-sdk');
const S3 = new AWS.S3({
signatureVersion: 'v4',
});
const sharp = require('sharp');
const BUCKET = process.env.BUCKET ? process.env.BUCKET : "mybucket";
const URL = process.env.URL ? process.env.URL : "http://localhost:5858"; // for local development