Skip to content

Instantly share code, notes, and snippets.

View kannan4k's full-sized avatar

Kannan Ponnusamy kannan4k

View GitHub Profile
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo apt-get install skype
@kannan4k
kannan4k / jenkins.json
Created December 2, 2015 10:22
Jenkins Jobs Automation
"jenkins": {
"jobs": {
"Test Chef integration - production stack": {
"description": "Production version of web stack",
"variable1": "value1",
"variable2": "value2",
"variable3": "value3",
},
"Test jenkins job": {
"description": "Development version of web stack",
@kannan4k
kannan4k / ex.py
Last active August 29, 2015 14:27
class DBInterfaceMeta(type):
# we use __init__ rather than __new__ here because we want
# to modify attributes of the class *after* they have been
# created
def __init__(cls, name, bases, dct):
if not hasattr(cls, 'registry'):
# this is the base class. Create an empty registry
print "Inside if"+str(cls)
print name
print bases
class Foo(object):
inherited_classes = []
fields = {}
@classmethod
def add_me(cls, subcls):
cls.inherited_classes.append(subcls)
print cls.inherited_classes
@classmethod
def add_field(cls, id_key)
fields[cls] = id_key
from tsheets.model import Model
class User(Model):
Model.add_field('id', 'int')
Model.add_field('username', 'str')
Model.add_field('email', 'str')
class Model(object):
accessors = {}
def __init__(self, hash = None, options = {}):
self._dynamic_accessors = []
if hash:
self.__class__.mass_assign(self, hash, {})
@classmethod
def add_field(cls, fname, type_f, options={}):
class TSheets::Repos::Users < TSheets::Repository
url "/users"
model TSheets::Models::User
actions :list, :add, :edit
filter :ids, [ :integer ]
filter :usernames, [ :string ]
filter :active, :boolean
filter :first_name, :string
filter :last_name, :string
filter :modified_before, :datetime
require 'date'
class TSheets::Repository
attr_accessor :bridge, :cache
@@allowed_classes_for_spec = {
boolean: [ ::TrueClass, ::FalseClass ],
integer: [ ::Fixnum ],
string: [ ::String, ::Symbol ],
date: [ ::Date, ::DateTime ],
class TSheets::Models::User < TSheets::Model
field :id, :integer
field :username, :string
field :email, :string
field :first_name, :string
field :last_name, :string
field :group_id, :integer
field :manager_of_group_ids, [ :integer ]
field :employee_number, :integer
field :salaried, :boolean
class TSheets::Model
attr_accessor :cache, :_dynamic_accessors
@@_models ||= {}
@@_accessors ||= {}
def initialize(hash = nil, options = {})
self.cache = options[:cache] || TSheets::SupplementalCache.new
self._dynamic_accessors ||= []
self.class.mass_assign self, hash, self.cache, {} if hash