Skip to content

Instantly share code, notes, and snippets.

View levlaz's full-sized avatar

Lev Lazinskiy levlaz

View GitHub Profile
@levlaz
levlaz / Vagrantfile
Created December 3, 2015 23:53
Local Vagrant File
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box_check_update = false
config.vm.provider "virtualbox" do |vb|
config.vm.box = "ubuntu/trusty64"
end
@levlaz
levlaz / docker.sh
Created December 4, 2015 17:27
Docker 1.9
#!/bin/bash
set -ex
echo '>>>> Installing Docker'
DEBIAN_FRONTEND=noninteractive apt-get install -qq lxc btrfs-tools libcgmanager0
service lxc stop
sed -i 's|10\.0\.3|10.0.4|g' /etc/default/lxc
deployment:
push_to_linode:
branch: master
commands:
- git checkout master
- rsync -avz app [email protected]:/var/www
- rsync -avz migrations [email protected]:/var/www
- rsync -avz *.{py,txt} [email protected]:/var/www
@levlaz
levlaz / types_and_roles_demo.sql
Created March 28, 2016 19:11
Create Types and Roles If Not Exist in PostgreSQL
BEGIN;
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'task_status') THEN
create type task_status AS ENUM ('todo', 'doing', 'blocked', 'done');
END IF;
END
$$;
CREATE TABLE IF NOT EXISTS
@levlaz
levlaz / overide_ssl.py
Created April 8, 2016 02:00
SSL Helper for ESXi
#!/usr/bin/env python
"""
Overrides SSL verification for SmartConnect.
Usage:
from overide_ssl import get_context
# Append sslContext to your SmartConnect object init:
service_instance = connect.SmartConnect(host=args.host,
@levlaz
levlaz / example.sql
Created April 16, 2016 22:21
DB 101
CREATE TABLE person (
id int primary key,
name varchar(200),
age int
)
CREATE TABLE personAddress (
id int primary key
-- Below is the foreign key that links this table to the person table via the primary key (id)
person_id int references person(id),
Levs-MacBook-Pro-2:~ levlaz$ gem install rails -v 4.2.3
Fetching: rack-1.6.4.gem (100%)
Successfully installed rack-1.6.4
Fetching: rack-test-0.6.3.gem (100%)
Successfully installed rack-test-0.6.3
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /Users/levlaz/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.8/ext/nokogiri
import datetime
utc_now = datetime.datetime.utcnow()
local_now = datetime.datetime.now()
print("The Local Time is {0}".format(local_now))
print("The UTC Time is {0}".format(utc_now))
def test():
test_variable = 10
return test_variable
def test2(test_variable):
if test_variable == 10:
print(test_variable)
a = test()
test2(a)
class Test():
def test(self):
self.test_variable = 10
def test2(self):
if self.test_variable == 10:
print(self.test_variable)
a = Test()