Skip to content

Instantly share code, notes, and snippets.

@tonyfg
tonyfg / log_response_time.rb
Created September 14, 2018 09:14
Log Rails request response time
# config/initializers/log_response_time.rb
event_logger = ::Logger.new("#{Rails.root}/log/response_times.log")
event_logger.formatter = proc { |_severity, _datetime, _progname, msg|
"#{msg}\n"
}
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |_, started, finished, _, stats|
request_time = (finished - started) * 1000
controller = stats[:controller][0..-11].underscore
@mrmartineau
mrmartineau / stimulus.md
Last active May 16, 2025 13:02
Stimulus cheatsheet
@shivendra14
shivendra14 / Illustrator_Scale_Artboard_and_Artwork.jsx
Created September 17, 2017 14:19
Script to scale up Illustrator Assets
#target Illustrator
/*
Revision-1
Author: Shivendra Agarwal
Year: 2017
Title: Script to scale-up artwork and artboard above 15 Mpixel
*/
if ( app.documents.length > 0 )
alert("ERROR: \n Close all documents before running this script." );
@trandaison
trandaison / starUML.md
Last active May 26, 2025 14:53
Get full version of StarUML
@randallreedjr
randallreedjr / heroku-remote.md
Last active May 29, 2025 19:19
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git
@mattia-beta
mattia-beta / ddos.conf
Last active May 5, 2025 08:22
IPtables DDoS Protection for VPS
### 1: Drop invalid packets ###
/sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
### 2: Drop TCP packets that are new and are not SYN ###
/sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
### 3: Drop SYN packets with suspicious MSS value ###
/sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
### 4: Block packets with bogus TCP flags ###
@neckhair
neckhair / .dockerignore
Created November 15, 2016 09:48
Sample dockerignore for a Rails app
.git
.gitignore
README.md
#
# OS X
#
.DS_Store
.AppleDouble
.LSOverride
@michaellihs
michaellihs / tmux-cheat-sheet.md
Last active May 27, 2025 08:13
tmux Cheat Sheet
@chathudan
chathudan / BackupRestoreMySQLDatabase.md
Last active July 21, 2021 09:46
Back Up and Restore a MySQL Database

If you're storing anything in MySQL databases that you do not want to lose, it is very important to make regular backups of your data to protect it from loss. This tutorial will show you two easy ways to backup and restore the data in your MySQL database. You can also use this process to move your data to a new web server.

Back up From the Command Line (using mysqldump)

Back up your MySQL Database with Compress

Restoring your MySQL Database

Backing Up and Restoring using PHPMyAdmin

@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active May 20, 2025 11:56
Vanilla JavaScript Quick Reference / Cheatsheet