Skip to content

Instantly share code, notes, and snippets.

@ViktorOgnev
ViktorOgnev / gist:3160310
Created July 22, 2012 17:11
Check sudoku - solve sudoku
def check_sudoku(grid, p_info = False, gridsize = 9):
'''sudoku checker - enter True as second func. argument
to print more info
about check failures'''
def check_sudoku_complete_results(grid, gridsize = 9):
if type(grid) != list: return None, 'function accepts list, got %s instead' % (str(type(grid)))
if gridsize % 3 != 0: return None, 'incorrect size'
@ViktorOgnev
ViktorOgnev / gist:3160335
Created July 22, 2012 17:12
Check sudoku - solve sudoku
def check_sudoku(grid, p_info = False, gridsize = 9):
'''sudoku checker - enter True as second func. argument
to print more info
about check failures'''
def check_sudoku_complete_results(grid, gridsize = 9):
if type(grid) != list: return None, 'function accepts list, got %s instead' % (str(type(grid)))
if gridsize % 3 != 0: return None, 'incorrect size'
if len(grid) != gridsize:
#!/bin/bash
# clone ci repo
# install essential deps
cd ~
rm
apt-get update
apt-get install -y git curl make ruby1.9.1-dev
curl -L https://www.opscode.com/chef/install.sh | bash
gem install --no-ri --no-rdoc librarian-chef
Vagrant.configure("2") do |config|
config.vm.define 'ubuntu-14.04' do |c|
c.vm.hostname = "ubuntu-1404"
c.vm.box = "ubuntu-14.04"
c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
c.vm.provision :shell, inline: "apt-get update"
end
end
@ViktorOgnev
ViktorOgnev / instal_docker_debian_wheezy
Created March 25, 2015 09:52
Install docker on debian
echo "deb http://http.debian.net/debian wheezy-backports main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -t wheezy-backports linux-image-amd64
curl -sSL https://get.docker.com/ | sh
@ViktorOgnev
ViktorOgnev / parsereg.py
Last active October 20, 2017 14:01
parse windows registry file
with open("/Users/viktorognev/work/Workspace/ci/chef/cookbooks/ci/files/default/pssconfig.reg") as fp:
res = ""
for line in fp.readlines():
if '=' in line:
print line
name, value = line.split('=', 1)
if ':' in value:
if 'C:\\' in value:
vtype, data = "expand_string", value
else:
@ViktorOgnev
ViktorOgnev / dockercleanup
Last active September 23, 2015 16:07
remove stopped containers and untagged images
#!/bin/bash
# stop all
docker stop $(docker ps -a | awk '{print $1}')
# remove all containers
docker rm $(docker ps -a | awk '{print $1}')
# remove untagged images
docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
@ViktorOgnev
ViktorOgnev / build ubuntu-32bit
Created July 3, 2015 14:07
build 32bit-ubuntu docker images, run this script on trusty or newer
#!/bin/bash -ex
### Build a docker image for ubuntu i386.
### settings
arch=i386
suite=${1:-trusty}
chroot_dir="/var/chroot/$suite"
mkdir -p $chroot_dir
mkdir -p $chroot_dir/etc
mkdir -p $chroot_dir/etc/apt
@ViktorOgnev
ViktorOgnev / install pygit
Last active September 24, 2015 12:01
install pygit
apt-get install -y build-essential cmake python-dev libffi6 libffi-dev
wget https://github.com/libgit2/libgit2/archive/v0.23.0.tar.gz
tar xzf v0.23.0.tar.gz
cd libgit2-0.23.0/
cmake .
make
make install
ldconfig
pip install pygit2
@ViktorOgnev
ViktorOgnev / choco_and_cmder
Created September 28, 2015 10:34
install chocolatey and cmder
#!powershell
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
$env:PATH="$env:PATH;$env:ALLUSERSPROFILE\chocolatey\bin"
choco install cmder