Skip to content

Instantly share code, notes, and snippets.

View ranjib's full-sized avatar
🥁
having fun

Ranjib Dey ranjib

🥁
having fun
View GitHub Profile
@ranjib
ranjib / timer_reset.go
Created January 17, 2018 04:37
reef-pi reset timers
package main
import (
"fmt"
"github.com/boltdb/bolt"
"os"
"time"
)
const bucket = "timers"
@ranjib
ranjib / dd-user.txt
Created August 30, 2016 20:44
DD User email
Received: by 10.194.72.228 with SMTP id g4csp30259wjv;
Tue, 30 Aug 2016 13:32:34 -0700 (PDT)
X-Received: by 10.202.245.88 with SMTP id t85mr5521820oih.202.1472589154488;
Tue, 30 Aug 2016 13:32:34 -0700 (PDT)
Return-Path: <johnc.tyus@outlook.com>
Received: from SNT004-OMC1S9.hotmail.com (snt004-omc1s9.hotmail.com. [65.55.90.20])
by mx.google.com with ESMTPS id o41si11702005oto.113.2016.08.30.13.32.34
for <ranjib@pagerduty.com>
(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
@ranjib
ranjib / squash.go
Last active May 25, 2016 21:28
docker image squashing
import(
"github.com/docker/engine-api/client"
"github.com/docker/engine-api/types"
)
func Squash() {
defaultHeaders := map[string]string{"User-Agent": "abc-1.0"}
cli, _ := client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders)
ctx := context.Background()
saveBody, _ := cli.ImageSave(ctx, []string{"image-id"})
src := types.ImageImportSource{
@ranjib
ranjib / org1-prod.rb
Created June 18, 2015 22:13
Consuming common datra across environments using Chef's ruby environment DSL
# located at chef_repo/environments/org1-prod.rb
require 'deep_merge'
name 'org1-prod'
description 'Production environment for org1'
org1_yml_path = File.expand_path('../common/org1.yml', __FILE__)
common = YAML.load_file(org1_yml_path)
default_attributes(
common['default'].deep_merge!(
# declare all you org1-prod specific things here.
@ranjib
ranjib / upgrade.rb
Last active August 29, 2015 14:22
Upgrade chef
config(:chef, node_name: 'foo', client_key: '/path/to/client.pem', chef_server_url: 'https://foo.bar.com')
config(:ssh, user: 'foo', password: 'bar')
[
'sudo apt-get remove chef --purge -y',
'sudo rm -rf /opt/chef',
'sudo rm -rf /etc/chef/client.d',
'wget -c https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/13.04/x86_64/chef-xxx.deb',
'sudo dpkg -i chef-xxx.deb',
'sudo env -i /opt/chef/bin/chef-client',
'rm chef-xxx.deb'
execute 'apt-get source redis-server=2:2.8.19-3' do
cwd '/opt/foo'
creares '/opt/foo/redis-2.8.19'
end
# Using chef to create files with a time stamp or similar - in this case,
# the serial number in a DNS zone file - presents a problem, because the
# time stamp interferes with with idempotency. Here is a trick for solving
# this (thanks to Noah Kantrowitz for his input and suggestion!)
# The trick is to use the same template twice, once with a constant serial
# number to check for idempotency, and a second time with the "real" serial
# number. The actual serial number can be stored in an attribute.
# Initial serial number for the zone
@ranjib
ranjib / recipe_spec.rb
Last active August 29, 2015 14:12
ChefSpec memoization
let(:runner) do
memoized_runner('pd-gocd::agent') do |node|
#.....
end
end

Thanks for wanting to contribute to Chef! There are many ways to get involved in various areas of the project, tools, and documentation. This document will help you get started; the links below point to how-to-contribute information for each project.

An Overview of the Main Projects under the Chef Umbrella

The Chef Client

The Chef Development Kit

@ranjib
ranjib / recipe_spec.rb
Created September 18, 2014 17:11
Common Stubs
describe 'recipe[doit]' do
before(:each) do
stub_r3dparty_cookbooks
end
it 'some awesome specs do here' do
# assertion
end
end