Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Ranjib Dey ranjib

View GitHub Profile
@ranjib
ranjib / timer_reset.go
Created Jan 17, 2018
reef-pi reset timers
View timer_reset.go
package main
import (
"fmt"
"github.com/boltdb/bolt"
"os"
"time"
)
const bucket = "timers"
View dd-user.txt
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
docker image squashing
View squash.go
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 Jun 18, 2015
Consuming common datra across environments using Chef's ruby environment DSL
View org1-prod.rb
# 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 Aug 29, 2015
Upgrade chef
View upgrade.rb
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'
View test.rb
execute 'apt-get source redis-server=2:2.8.19-3' do
cwd '/opt/foo'
creares '/opt/foo/redis-2.8.19'
end
View chef_dns_zone_with_serial_number.rb
# 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 Aug 29, 2015
ChefSpec memoization
View recipe_spec.rb
let(:runner) do
memoized_runner('pd-gocd::agent') do |node|
#.....
end
end
View master-contributing.md

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

View recipe_spec.rb
describe 'recipe[doit]' do
before(:each) do
stub_r3dparty_cookbooks
end
it 'some awesome specs do here' do
# assertion
end
end
You can’t perform that action at this time.