Skip to content

Instantly share code, notes, and snippets.

View andymarthin's full-sized avatar
🏠
Working from home

Andy Marthin Christo andymarthin

🏠
Working from home
View GitHub Profile
@andymarthin
andymarthin / image-split.js
Last active September 5, 2021 19:02
jquery plugin image split to tiles
;(function( $, window ) {
var _defaults = {
row : 4, // tiles in x axis
column : 4, // tiles in y axis
activeTileClass: 'tileActive'
};
function extractActiveTile( $tiles ) {
if( $tiles.length > 0 ) {
var string_tiles = $tiles.split('|');
@andymarthin
andymarthin / 1. ELK.install
Created April 5, 2021 03:35 — forked from PavloBezpalov/1. ELK.install
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
INSTALL JAVA
$ sudo apt-get update && sudo apt-get install default-jre
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch
$ sudo update-rc.d elasticsearch defaults 95 10
$ sudo service elasticsearch restart
$ sudo service elasticsearch status
sudo visudo
%wheel ALL=NOPASSWD:/usr/sbin/passenger-status
#!/usr/bin/ruby
require 'open3'
require 'logger'
def get_list_passenger_process
process, stderr, status = Open3.capture3("passenger-status")
list_process = process.gsub(/^(.*?)(Requests in queue: (.$))/m, '')
list_process = list_process.split("\n *")
list_process = list_process.reject(&:empty?).map do |process|
@andymarthin
andymarthin / pre-commit
Last active May 10, 2020 14:23 — forked from jameslafa/pre-commit
Git pre-commit to avoid commiting breakpoints, secret files, etc.
#!/usr/bin/env ruby
# Place in your project .git/hooks/pre-commit
# Heavily inspired by https://raw.githubusercontent.com/balabhadra/githooks/master/pre-commit, so thank you to him
############# CONFIGURATION
# The two sections of regular expressions below ("forbidden" and "warning")
# will trigger a commit failure, *if* they are found on an added or edited line.

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
#!/bin/sh
# This is my script for setting up ubuntu machines in
# a similar setup to how thoughtbot's laptop script
# works (https://github.com/thoughtbot/laptop)
# how to run
# curl --remote-name [change to raw file url] && sudo chmod +x ubuntu.sh && ./ubuntu.sh 2>&1 | tee ~/laptop.log
sudo apt update && sudo apt upgrade -y
@andymarthin
andymarthin / upgrade heroku postgres plan.md
Last active April 26, 2019 06:37 — forked from zulhfreelancer/upgrade.md
How to upgrade Heroku Postgres database plan?
  1. Assuming you have multiple Heroku apps and Git remote like so:
development https://git.heroku.com/xxx.git (fetch)
development https://git.heroku.com/xxx.git (push)
origin      [email protected]:xxx/xxx.git  (fetch)
origin      [email protected]:xxx/xxx.git  (push)
production  https://git.heroku.com/xxx.git (fetch)
production  https://git.heroku.com/xxx.git (push)
staging https://git.heroku.com/xxx.git (fetch)
@andymarthin
andymarthin / heroku_pg_db_reset.md
Created April 11, 2019 07:46 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate

@andymarthin
andymarthin / csv_export.rb
Last active May 17, 2019 11:53 — forked from foxumon/csv_export.rb
Export table to CSV with all attributes in rails console
require 'csv'
file = "#{Rails.root}/public/data.csv"
table = User.all;0 # ";0" stops output. Change "User" to any model.
CSV.open( file, 'w' ) do |writer|
writer << table.first.attributes.keys
table.each do |s|
writer << s.attributes.values