Skip to content

Instantly share code, notes, and snippets.

View vi4m's full-sized avatar
:atom:
coding

✪ vi4m Marcin Kliks vi4m

:atom:
coding
View GitHub Profile
@vi4m
vi4m / puppet.py
Created December 10, 2012 14:07
deployment
@plugin.register(chain='deployment', requires=[], priority=0)
def puppet(deployment_id):
if not settings.PUPPET_DB_URL:
return True
deployment = Deployment.objects.get(id=deployment_id)
return deployment.puppet_certificate_revoked
@vi4m
vi4m / gist:4554591
Last active December 11, 2015 05:48

Ralph shell

UF options

  • dir()
  • autocompletion - po ewaluacji
  • root

Jak wyszukiwac obiekty wg atrybutow?

  • Po Primary Key
import datetime
results = {}
from rq import Queue, use_connection
class InProgressException(Exception):
pass
def test(*args, **kwargs):
(ralph)ralph@assets-www:~/lib$ pip freeze
Django==1.4.2
Jinja2==2.6
MySQL-python==1.2.3
Pillow==1.7.8
PyYAML==3.10
Pygments==1.6
SQLAlchemy==0.7.8
South==0.7.6
Sphinx==1.1.3
@vi4m
vi4m / gist:5748434
Last active December 18, 2015 07:39
Pomysły na salkę wpisujcie miasta!
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@vi4m
vi4m / gist:5276eb9c4442b787aad9
Last active August 29, 2015 14:06
Konfiguracja edytor pod pythona

VIM

cat ~/.vim/ftplugin/python.vim

set tabstop=8 
set expandtab 
set shiftwidth=4 
syntax on
set autoindent

Beautifull function decorator

Write decorator which prints function arguments and result. When decorated on given function with arbitrary number of arguments, invocation of this function should print-out arguments, and the result.

    @deco
    def sum_(x, y):
        return x + y

Write simple Singleton.

Write Singleton which returns the same object every time. You can use the implementation you want.

first_object = Singleton(name='test1')
second_object = Singleton(name='test2')
print(first_object.name == second_object.name)
@vi4m
vi4m / struct_and_inheritance.swift
Created December 28, 2015 12:46 — forked from AliSoftware/struct_vs_inheritance.swift
Swift-Struct-Inheritance
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/