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
@orioltf
orioltf / check_vars_haml.md
Last active July 6, 2019 23:45
#HAML: Checking variables in partials
  1. Check if a page variable has been defined
    1. Set variables in a page (page.html.haml) at the very biginning of the file:

      ---
      variable: value
      variable2: value 2
      ---
@WaKeMaTTa
WaKeMaTTa / order-rails-controller-callbacks.md
Last active July 29, 2019 12:29
Order of Rails Controller Callbacks

Order of Rails Controller Callbacks

Rails 4.x

Started GET "/" for 127.0.0.1 at 2017-05-19 14:17:18 +0200
  Processing by WelcomeController#index as HTML
    prepend_around_action
    prepend_before_action
 before_action
@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
@maxdbn
maxdbn / AWS_Single_LetsEncrypt.yaml
Created February 26, 2018 12:32 — forked from tony-gutierrez/AWS_Single_LetsEncrypt.yaml
AWS Elastic Beanstalk .ebextensions config for single instance free SSL using letsencrypt certbot and nginx. http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/
# Dont forget to set the env variable "certdomain", and either fill in your email below or use an env variable for that too.
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
@ismailakbudak
ismailakbudak / docker-and-docker-compose-commands.bash
Last active October 28, 2019 18:38
Usefull docker commands
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
docker rm <hash> # Remove the specified container from this machine
docker rm $(docker ps -a -q)
@steinnes
steinnes / 01_setup_swap.config
Last active October 30, 2019 17:32
EB config file which executes setup_swap.sh
container_commands:
01setup_swap:
command: "bash .ebextensions/setup_swap.sh"
@ryancolorcafe
ryancolorcafe / snippets.cson
Created August 1, 2017 18:58
Ruby, ERB, and Haml Pry and ByeBug snippets for Atom text editor
# Ruby
'.source.ruby':
'Ruby pry':
'prefix': 'pry'
'body': 'require "pry"\nbinding.pry'
# ERB
'.text.html.ruby,
.text.html.erb':
'ERB pry':
@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
@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
# This is to enable WS support. Credits: # https://gist.github.com/Bubelbub/0a942a0d51a3d329897d
# THIS WORKS! for running the example 5.0.0.beta1 chat app on a single instance Elastic beanstalk AWS instance
files:
"/etc/nginx/conf.d/websockets.conf" :
content: |
upstream backend {
server unix:///var/run/puma/my_app.sock;
}