Skip to content

Instantly share code, notes, and snippets.

ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub
@barsbek
barsbek / redis_server.sh
Created October 7, 2018 16:18
daemonize redis-server
redis-server --daemonize yes
@barsbek
barsbek / gist:322e4ab16a8386f1df94ce3fbc02037d
Created July 25, 2018 20:49
windows: restore dump into postgresql
psql.exe -U postgres -d balloon_development -f D:\temp\db.dump
@barsbek
barsbek / check_multiple.js
Created June 10, 2018 11:54
check multiple checkboxes while shift key pressed
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(c => c.addEventListener('click', handleCheck));
let lastChecked = null;
function handleCheck(e) {
let inBetween = false;
if(e.shiftKey && this !== lastChecked) {
checkboxes.forEach(c => {
@barsbek
barsbek / config.bat
Created June 9, 2018 09:24
change default wsl to ubuntu
// run the command in windows cmd
wslconfig /s Ubuntu
// to show list of installed subsystems
wslconfig /l
@barsbek
barsbek / scale_site.js
Created June 6, 2018 08:50
scale desktop version depending on device width
if( true ) {
var ww = ( $(window).width() < window.screen.width ) ? $(window).width() : window.screen.width; //get proper width
var mw = 1024;
var ratio = ww / mw;
if( ww < mw){
$('#viewport').attr('content', 'initial-scale=' + ratio + ', maximum-scale=' + ratio + ', minimum-scale=' + ratio + ', user-scalable=yes, width=' + ww);
}else{
$('#viewport').attr('content', 'initial-scale=1.0, maximum-scale=2, minimum-scale=1.0, user-scalable=yes, width=' + ww);
}
}
# regexp
# to create non-capturing group use:
(?:)
# (?:b) matches b without capturing it
@barsbek
barsbek / swiper_carousel.js
Created April 21, 2018 05:37
bootstrap: add swiper to carousel
@barsbek
barsbek / backup.sh
Created March 28, 2018 06:20
linux: backup device
# windows 10 goes into hibernation on shutdown. Turn it off in battery settings to make disks C & D writable
dd if=/dev/sdX bs=4K status=progress| gzip -c > /path/to/backup.img.gz
def list_squared(m, n)
divs_hash = {}
(m..n).reduce([]) do |result, i|
sum = 1
divs = [1]
for k in (2..i/2)
if (i % k).zero?
current = (i/k)
if divs_hash.has_key?(current.to_s)
divs_hash[current.to_s].each do |c|