Skip to content

Instantly share code, notes, and snippets.

View synsa's full-sized avatar

Steve Lang synsa

View GitHub Profile
@synsa
synsa / bootstrap-memo.md
Created February 25, 2019 08:56 — forked from yalab/bootstrap-memo.md
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add [email protected] jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@synsa
synsa / deploy.rb
Created February 26, 2019 20:12 — forked from PWSdelta/deploy.rb
A sample Capistrano deploy.rb file I use as a base for all my projects. It's a straightforward & doesn't add much custom functionality besides symlinking my database.yml into my project from a folder outside of my application (considered good security practice).
require 'bundler/capistrano'
# Include this if you want to be able to set up different deployment stages (i.e. beta, stage, etc.)
# require 'capistrano/ext/multistage'
set :application, "example.com"
set :user, "linuxusername"
default_run_options[:pty] = true
set :use_sudo, true
@synsa
synsa / deploy.rb
Created February 26, 2019 20:13 — forked from col/deploy.rb
Example Capistrano deploy file. This is a basic example that I plan to improve soon. Update 1: Added :admin_runner option to ensure deployment directories are created with the correct owner. Update 2: Added better support for multiple environments and added rails:console rails:dbconsole tasks.
require 'rvm/capistrano'
require 'bundler/capistrano'
require 'capistrano/ext/multistage'
load 'deploy/assets'
set :stages, ["staging", "production"]
set :default_stage, "production"
set :user, '?'
set :admin_runner, '?'
@synsa
synsa / winpath,sh
Created February 28, 2019 05:13 — forked from aseering/winpath,sh
#!/bin/bash
echo "$@" | sed -e 's|\\|/|g' -e 's|^\([A-Za-z]\)\:/\(.*\)|/mnt/\L\1\E/\2|'
@synsa
synsa / git-pull-all
Created March 1, 2019 17:11 — forked from grimzy/git-pull-all
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@synsa
synsa / signal_catching.rb
Created March 14, 2019 22:53 — forked from sauloperez/signal_catching.rb
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@synsa
synsa / apache.rb
Created March 15, 2019 18:12 — forked from nulltask/apache.rb
parsing apache access log with ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'apache_log_regex'
require 'date'
format = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"'
parser = ApacheLogRegex.new(format)
File.readlines('/path/to/access-log').collect do |line|
@synsa
synsa / artisan.php
Created March 29, 2019 18:48 — forked from vkbansal/artisan.php
Tying to use artisan migrate commands outside laravel
<?php
require_once "vendor/autoload.php";
use Symfony\Component\Console\Application;
use Illuminate\Database\Console\Migrations;
use Pimple\Container;
$container = new Container();
$container['migration-table'] = 'migration';
@synsa
synsa / Version20121011141021.php
Created March 29, 2019 19:24 — forked from ziadoz/Version20121011141021.php
Doctrine DBAL and Migrations Example
<?php
/*
* /path/to/migrations/directory/Version20121011141021.php
*/
namespace ExampleMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class Version20121011141021 extends AbstractMigration
@synsa
synsa / sniff.rb
Created April 3, 2019 22:56 — forked from azet/sniff.rb
boilerplate code for ruby packet sniffer
#!/usr/bin/env ruby
require 'packetfu'
# filter = argv[0] - tcpdump style.
# e.g. 'dst host bla.dom.tld and port http and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# to cap. http traffic. or 'host W.X.Y.Z' to cap a speficic host/ip
cap = PacketFu::Capture.new(:start => true)
cap.save(:filter => ARGV[0])