Skip to content

Instantly share code, notes, and snippets.

View vitalyp's full-sized avatar
💭
HaPpY

Vitaly Pestov ua vitalyp

💭
HaPpY
View GitHub Profile
@vitalyp
vitalyp / doPendulum.js
Created March 14, 2015 08:50
Single line Pendulum stroke algorythm
var inc = 1,
slideCount = 30,
slideIndex = 1;
// PENDULUM ANIMATION
// -------------------------------
function doPendulum() {
slideIndex += (inc *= (((slideIndex >= slideCount-1 || slideIndex <= 0 ) && -1) || 1));
}
// where:
@vitalyp
vitalyp / pyramid_matrix.rb
Created October 19, 2015 12:10
pyramid_matrix
def pyramid_matrix n
nums = (0..(n/2.0).ceil-1).map{|m| [[m+1]*([4*n-8*m-4,1].max)] }.flatten
mx, ci, cd = ([!:&]*n*n).each_slice(n).to_a, n, 0
nums.each do |i|
ci = ci - 1
mx[cd][ci] ||= i
if ci == 0 || mx[cd][ci-1]
ci, cd = n - cd - 1, ci
mx = mx.transpose.map(&:reverse)
end
@vitalyp
vitalyp / koding_mstsc.sh
Last active November 6, 2015 08:49
KodingDesktopServerInstallScript
wget -O Koding_Desktop_Server_Install.sh "https://docs.google.com/feeds/download/documents/export/Export?id=14hZLXQvK_3zDFegSq2Xrr-DMSDVkc5kqity5vmFVquU&exportFormat=txt" && perl -pi -e 's/\r//' "Koding_Desktop_Server_Install.sh" && bash "Koding_Desktop_Server_Install.sh" && echo -e " \033[1;5;36m FINE! Now sudo reboot, and then connect me with mstsc.exe! \033[0m "

If you want to revert changes made to your working copy, do this:

git checkout .

If you want to revert changes made to the index (i.e., that you have added), do this. Warning this will reset all of your unpushed commits to master!:

git reset

If you want to revert a change that you have committed, do this:

# with comments
def get_random_bytes count
random = `dd if=/dev/urandom | head -c #{count}`
puts "random data is:\n#{random}\n\r-----length is: #{random.length}"
random
end
def clip_encoded_with data_str, encoding
encoded = data_str.encode(encoding, invalid: :replace, undef: :replace, replace: '')
@vitalyp
vitalyp / seneca.md
Last active June 24, 2019 15:31
SenecaJS - A microservices toolkit for Node.js
@vitalyp
vitalyp / heroku_mc.sh
Created June 29, 2017 08:51
How to setup midnight-commander file manager to heroku
#!/bin/bash
# Create file:
# cat > heroku_mc.sh <<- "EOF"
# this file contents
# EOF
mkdir -p /tmp
McDIR="/tmp/mc";McBinDIR="$McDIR/bin";mkdir -p $McDIR;cd $McDIR;TmpDIR="/temp_deb";mkdir -p $McDIR/$TmpDIR;cd $McDIR/$TmpDIR;wget http://security.ubuntu.com/ubuntu/pool/universe/m/mc/mc_4.8.1-2ubuntu1_amd64.deb;ar -x mc_4.8.1-2ubuntu1_amd64.deb;tar -xvf data.tar.gz;
mv usr/* $McDIR;mkdir $McDIR/etc;mv ./etc/mc/* $McDIR/etc;cd $McDIR;rm -rf $TmpDIR;
@vitalyp
vitalyp / heroku midnight commander
Created June 29, 2017 08:58
Midnight Commander for Heroku
At `heroku run bash` session:
wget -O - https://gist.githubusercontent.com/vitalyp/b7ee6db012c33709f7f8de5e58dd05b5/raw/846999eb9896ae4b3280422561cb1d510cefdb53/heroku_mc.sh | bash
@vitalyp
vitalyp / getDiff.sh
Created January 30, 2018 10:28
Get diff Files since last 5 commits
git archive -o update.zip HEAD $(git diff --name-only HEAD~5)
@vitalyp
vitalyp / lines_numbers.html
Last active June 24, 2019 15:29
MAGIC_HTML_TEST (see line numbers on each row)
<!-- HTML generated using hilite.me --><div style="background: #000000; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10