Skip to content

Instantly share code, notes, and snippets.

View kannan4k's full-sized avatar

Kannan Ponnusamy kannan4k

View GitHub Profile
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
if data['supplemental_data']
data['supplemental_data'].inject({}) do |sum, parts|
sum
key, value = parts
sum[key.to_sym] = value.values
sum
end
else
{}
end
class KmlUpdateHandler(tornado.web.RequestHandler):
counter = 0
timeout = 10
global_dict = {}
lock = threading.Lock()
@classmethod
def add_to_global_dict(cls, reference, unique_id):
cls.global_dict[unique_id] = reference
import logger
class Results(object):
def __init__(self, url, options, model, bridge, cache, is_singleton = False, mode = "list")
self.url = url
self.options = options
self.model = model
self.name = "users"
self.index = -1
self.loaded = []
@kannan4k
kannan4k / api.rb
Last active August 29, 2015 14:25
def load_next_batch
response = self.bridge.next_batch(self.url, self.name, self.options, self.is_singleton)
puts "Self.model"
puts self.model
batch = response[:items]
self.has_more = !self.is_singleton && response[:has_more]
if self.is_singleton
self.loaded = [ self.model.from_raw(batch, self.cache, response[:supplemental] || {}) ]
else
self.loaded += batch.map { |o| self.model.from_raw(o, self.cache, response[:supplemental] || {}) }
class TSheets::Model
def self.from_raw(hash, cache, supplemental = {})
instance = hash.inject self.new(cache) do |o, p|
k, v = p
casted = cast_raw(v, k, cache)
has_key = o.attributes.keys.include? k
if !has_key
o.instance_variable_set "@#{k}".to_sym, casted
o.define_singleton_method k do
o.instance_variable_get "@#{k}".to_sym
@kannan4k
kannan4k / sample
Created June 18, 2015 17:14
sample
sample
@kannan4k
kannan4k / check_multiple.py
Last active August 29, 2015 14:20
check_multiple_nagios_commands
#! /usr/bin/env python
import sys
import getopt
import optparse
import commands
import shlex
def returnStatus(statusInfo,checkMode):
statusResult = None
@kannan4k
kannan4k / terminal_output
Created April 22, 2015 03:19
Portal Pull Requests Output
Last login: Wed Apr 22 01:27:32 on ttys002
kannan@Kannans-MacBook-Pro: ~/ep/lg_chef
$ bash test/scripts/run_tests.sh
==> portal-pull-requests-kiosk: VM not created. Moving on...
==> portal-pull-requests-display: VM not created. Moving on...
==> portal-pull-requests-nuc: VM not created. Moving on...
==> portal-pull-requests: VM not created. Moving on...
Not managing knife client because => chef_zero
All ssh keys presented below
4096 59:10:22:6f:0e:c5:ba:12:0e:34:f5:e3:7c:4b:7b:18 /Users/kannan/.ssh/id_rsa (RSA)
4096 59:10:22:6f:0e:c5:ba:12:0e:34:f5:e3:7c:4b:7b:18 /Users/kannan/.ssh/id_rsa (RSA)
Converting from raw image file="../files/ipxe.usb" to file="../files/ipxe_portal-pull-requests-nuc.vmdk"...
Creating dynamic image with size 409600 bytes (1MB)...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.