Skip to content

Instantly share code, notes, and snippets.

View NazarK's full-sized avatar

Nazar Kuliyev NazarK

  • Almaty, Kazakhstan
View GitHub Profile
@NazarK
NazarK / deploy.rb
Last active May 31, 2018 02:32
mina 1.2.3 deploy.rb with customizations (data pull from server, push to repo)
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
require 'mina/rvm' # for rvm support. (https://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
@NazarK
NazarK / dev_ops_server_ror_prepare.sh
Last active August 17, 2023 16:02
VDS (ubuntu) RoR app prerequisites (assuming postgres db)
#supposed to copy paste lines from here to terminal
apt -y update
apt -y upgrade
#usefull packages
#removed libqt4-dev - breaking installation
apt -y install mlocate lynx libjemalloc-dev mc vim imagemagick libmagickwand-dev postgresql postgresql-contrib libpq-dev nginx curl git nodejs zip htop resolvconf
#for debian
apt -y install gnupg2 dirmngr sudo locate
@NazarK
NazarK / call_soon.js
Created September 1, 2017 08:45
call_soon (for delayed form submit for example)
function call_soon(interval_id, callback, timeout) {
if(!timeout) {
timeout = 500
}
clearTimeout(window[interval_id])
window[interval_id] = setTimeout(callback,timeout)
}
@NazarK
NazarK / js_calc.js
Created June 16, 2017 11:58
calculates sum of elements values having data-sum parameter (this is to be called on target elements change, or on page keydown)
// example: <span class="with_spaces" data-parent="table" data-sum="input.unsold"></span>
sum_all = function(elements,callback) {
var sum = 0;
elements.each(function() {
if(!callback) {
var el_val = parseInt( ($(this).val() || $(this).html()).replace(/ /g,"")) || 0
sum += el_val
} else {
@NazarK
NazarK / code.js
Created October 15, 2016 14:30
arduino temperature meter with display (lm 35, lcd1602)
/*
temperature meter
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
@NazarK
NazarK / benchmark.js
Created November 19, 2015 10:03
simple js profiling
this.BENCHMARK = {
start_time: {},
start: function(label) {
console.log("bm start: "+label)
this.start_time[label] = new Date().getTime()
},
stop: function(label) {
past = new Date().getTime() - this.start_time[label]
console.log("bm stop: "+label+" "+past+"ms")
}
@NazarK
NazarK / gist:056bcedd76a5d05424d4
Created March 13, 2015 13:08
git push script with optional custom comment
#!/bin/bash
echo "commiting changes"
git add .
if [ "$1" != "" ]; then
git commit -am "$1"
else
echo "using empty comment"
git commit -am "-"
fi
@NazarK
NazarK / gist:9566de0db8fb603dda98
Created March 13, 2015 03:47
some extra commands that I use for mina gem, simple deployment with thin
#universal commands
task :shell do
system "echo 'logging into shell on server'"
system "ssh #{user}@#{domain} -t \"cd #{deploy_to}/current; bash --login\""
end
task :log do
queue 'echo "Contents of the log file are as follows:"'
queue "cd #{deploy_to}/current && tail -f log/production.log -n 100"
end
# git time log
# by NK
# usage "ruby git-timelog.rb" in git repository
#
# based on
# Simple Git Analyzer
#
# WORK IN PROGRESS :)
#
# Tobin Harris (tobin@tobinharris.com)