Skip to content

Instantly share code, notes, and snippets.

@ivan-leschinsky
ivan-leschinsky / db_on_js.js
Created January 22, 2016 12:51
simple indexDB for js workers or another
// Create/open database
var db, dbVersion = 1, request = indexedDB.open("simpleDB", dbVersion)
request.onerror = function (event) {
console.log("Error creating/accessing IndexedDB database");
};
Ion.with(this)
.load("https://url")
.basicAuthentication("user", "pass")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null) {
// Error loading url
@ivan-leschinsky
ivan-leschinsky / remove_branches.sh
Created June 7, 2016 09:40
Removes all local git branches with name containing your string
# my-prefix- is branches prefix
git branch | grep my-prefix- | xargs git branch -D
@ivan-leschinsky
ivan-leschinsky / my_db.rake
Created August 17, 2016 09:39 — forked from jay16/my_db.rake
rails backup DB
#encoding: utf-8
require "fileutils"
namespace :my_db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
desc "usage - bundle exec rake my_db:backup RAILS_ENV=production MAX=15 DIR=db/db.bak"
task :backup => [:environment] do
# config base dir
datestamp = Time.now.strftime("%Y%m%d%H%M")
base_path = Rails.root
backup_folder = File.join(base_path, ENV["DIR"] || "backups")
FileUtils.mkdir_p(backup_folder) unless File.exist?(backup_folder)

macOS 10.12 Sierra Setup

Custom recipe to get macOS 10.12 Sierra running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.11 El Capitan setup recipe and 10.10 Yosemite setup recipe. I am currently tweaking this for 10.12 Sierra and expect to refine this gist over the next few weeks.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. I generally reinstall each computer from scratch every 6 months, and I do not perform upgrades between releases.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your o

@ivan-leschinsky
ivan-leschinsky / sleepin.sh
Created August 7, 2017 21:32
Functions for sleep mac in time
# Schedule sleep in X minutes, use like: sleepin 60
function sleepin() {
local minutes=$1
local datetime=`date --date "now + ${minutes} minutes" +"%m/%d/%y %H:%M:%S"`
echo "Will sleep on ${datetime}"
sudo pmset schedule sleep "$datetime"
}
# Cancels all sleep
@ivan-leschinsky
ivan-leschinsky / my_zsh_theme.sh
Last active August 16, 2017 15:07
My theme for zsh
# before: git clone https://github.com/olivierverdier/zsh-git-prompt.git
# my theme based on candy and nebirhos:
# RVM component of prompt
ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[green]%}["
ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"
# do this before using haskell implementation:
# https://github.com/olivierverdier/zsh-git-prompt#haskell-optional
@ivan-leschinsky
ivan-leschinsky / install-redis.sh
Last active October 4, 2017 08:18 — forked from FUT/install-redis.sh
Install Redis 4.0.2 on EC2
# 1. Install Linux updates, set time zones, followed by GCC and Make
# sudo yum -y update
# sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
# /etc/localtime
# sudo yum -y install gcc make
# 2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
@ivan-leschinsky
ivan-leschinsky / fix_alfred_ruby_10.13.sh
Created October 9, 2017 11:40
Use alfred ruby worflows on High Sierra
# Use system ruby and install some gems there
# if you're using RVM:
rvm use system && sudo gem install alfred-workflow mixlib-shellout
# if you're using chruby
chruby system
sudo gem install alfred-workflow mixlib-shellout
@ivan-leschinsky
ivan-leschinsky / playpause.applescript
Last active August 26, 2025 19:44
Applescript play/pause scripts for the VLC, iTunes, Spotify, Deezer
(*
-- When running each app separately
tell application "Deezer"
if it is running then
set old to (path to frontmost application as text)
tell application "Deezer"
reopen
activate
end tell
tell application "System Events" to key code 49