Skip to content

Instantly share code, notes, and snippets.

View vasi's full-sized avatar

Dave Vasilevsky vasi

  • Montreal
View GitHub Profile
@vasi
vasi / tarpv
Created June 2, 2014 01:23
Create a tarball, using a progress bar
#!/usr/bin/env bash
# First arg is always option
arg1="$1"
shift
# Find first non-option
for i in "$@"; do
if [[ -z "$dir" && "$i" != -* ]]; then
dir="$i"
@vasi
vasi / gist:107d03974babaa3ca6a2
Created July 29, 2014 17:03
Vagrant for docker, trusty
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.provision :docker
config.vm.provision :shell, :inline => <<-EOT
apt-get install -y curl git vim

/cpp/bin/

@vasi
vasi / test.rss
Last active August 29, 2015 14:07
Test RSS for full-text-rss-docker
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title>WordPress News</title>
<atom:link href="https://wordpress.org/news/feed/" rel="self" type="application/rss+xml" />
<link>https://wordpress.org/news</link>
<description>WordPress News</description>
@vasi
vasi / autokittens.js
Last active August 29, 2015 14:08
autokittens.js fix
function buildUI() {
var tableContainer = document.createElement('div');
tableContainer.style.width = '100%';
tableContainer.style.height = '50px';
tableContainer.style.bottom = '0px';
tableContainer.style.position = 'absolute';
tableContainer.innerHTML = '<table id="timerTable" style="width: 100%; table-layout: fixed;"></table>';
document.body.appendChild(tableContainer);
document.getElementById('game').style.marginBottom = '50px';
document.getElementById('footerLinks').style.marginBottom = '60px';
@vasi
vasi / capture3.rb
Created December 16, 2014 18:40
Open3::capture3 for Ruby 1.8.x
#!/usr/bin/ruby
def capture3(*cmd)
# Force no shell expansion, by using a non-plain string. See ruby docs:
#
# `If the first argument is a two-element array, the first element is the
# command to be executed, and the second argument is used as the argv[0]
# value, which may show up in process listings.'
cmd[0] = [cmd[0], cmd[0]]
#!/bin/sh
dir="$1"
cd "$dir"
# Add new or changed files
git ls-files --exclude-standard -o -m -z | xargs -0r git add
# Commit changes, if any
if ! git diff --cached --quiet; then
@vasi
vasi / bpc-tar
Created January 4, 2015 18:27
BackupPC_tarCreate wrapper
#!/usr/bin/perl
use warnings;
use v5.12;
use File::Basename qw(dirname);
use Data::Dumper;
sub usage {
print <<USAGE;
bpc-tar HOST DIR
@vasi
vasi / squares.py
Last active August 29, 2015 14:14
#!/usr/bin/python3
from math import sqrt, log
from sys import argv
N = int(argv[1])
primes = list()
for i in range(2, int(sqrt(N + 1))):
if not any(i % p == 0 for p in primes):
primes.append(i)
@vasi
vasi / test
Last active August 29, 2015 14:20
test
test4