Skip to content

Instantly share code, notes, and snippets.

Amit Saha amitsaha

View GitHub Profile
@amitsaha
amitsaha / dynamodbtablescan.ps1
Created Nov 16, 2018
Powershell + DynamoDB table scan
View dynamodbtablescan.ps1
function Get-DynamoByPrefix($table, $keyPrefix)
{
$region = "ap-southeast-2"
$regionEndpoint=[Amazon.RegionEndPoint]::GetBySystemName($region)
$client = New-Object Amazon.DynamoDBv2.AmazonDynamoDBClient($regionEndpoint)
$req = New-Object Amazon.DynamoDBv2.Model.ScanRequest
$req.TableName = $table
$result = $client.Scan($req)
$result.Items | Where-Object {$_.Key.S.StartsWith($keyPrefix)} | ForEach-Object {
@amitsaha
amitsaha / test.go
Created Sep 21, 2018
golang format string demo
View test.go
package main
import (
"html/template"
"log"
"os"
"fmt"
)
type Person struct {
View gist:67082d0ae9f8a78dcb80ebeaaef86a5f
package main
import (
"log"
"os"
"os/signal"
"syscall"
"time"
)
View gist:afd3bd04521f25abce48259e42933616
https://tickets.puppetlabs.com/browse/PDK-460
Update gemfile based on http://razorconsulting.com.au/setting-up-puppet-module-testing-from-scratch-part-ii-beaker-for-module-testing.html
http://www.xkyle.com/getting-started-puppet-acceptance-tests-with-beaker/
pdk bundle install
pdk bundle update
pdk bundle --exec rake beaker
pdk bundle -- exec rake beaker:sets
@amitsaha
amitsaha / consumer.go
Created Dec 11, 2017 — forked from simpleton/consumer.go
Golang auto-reconnect rabbitmq consumer
View consumer.go
package base
import (
"errors"
"fmt"
"github.com/manucorporat/try"
"github.com/simpleton/beego"
"github.com/streadway/amqp"
"math/rand"
"model/helper"
@amitsaha
amitsaha / webapp.Dockerfile
Created Oct 25, 2017
Dockerfile for running a HTTP server on port 8000
View webapp.Dockerfile
# Build me using: docker build -t amitsaha/webapp .
FROM python:3
CMD ["python3", "-m", "http.server"]
@amitsaha
amitsaha / role_arn_to_session.py
Created Sep 13, 2017 — forked from gene1wood/role_arn_to_session.py
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
View role_arn_to_session.py
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@amitsaha
amitsaha / git-reverted?.md
Created Aug 9, 2017
Figure out whether a git reverted commit has been reverted
View git-reverted?.md

We have a commit, which was reverted, and then re-reverted, and it goes on. How do you find your original commit is now reverted or re-reverted?

$ git log --oneline  | grep "<commit message>" | grep  "Revert" | wc -l

If the number is even, your original change is in the repo, else not.

View keybase.md

Keybase proof

I hereby claim:

  • I am amitsaha on github.
  • I am amitsaha (https://keybase.io/amitsaha) on keybase.
  • I have a public key ASCzIDUse63Kj8CYSKomoMwAHJrKJvLQMxx8O7jG_jAfpAo

To claim this, I am signing this object:

@amitsaha
amitsaha / happy_git_on_osx.md
Created Sep 21, 2016 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X
View happy_git_on_osx.md

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
You can’t perform that action at this time.