Skip to content

Instantly share code, notes, and snippets.

@abhisek
abhisek / psp.yml
Created March 17, 2020 09:10
PodSecurityPolicy to Prevent hostPath Mount
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: developers-psp
spec:
privileged: false
allowPrivilegeEscalation: false
hostNetwork: false
hostPID: false
hostIPC: false
@clzola
clzola / install-redis.sh
Last active March 23, 2022 19:20
Bash script for installing Redis on Ubuntu 16.04
#!/bin/bash
# Install the Build and Test Dependencies
apt-get update
apt-get install -y curl build-essential tcl
# Download and Extract the Source Code
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
@ciaranarcher
ciaranarcher / golang-cheat.md
Last active December 27, 2018 14:26
golang cheatsheet

Types

type Vertex struct {
    Lat, Long float64
}

Maps

@iconara
iconara / start_cluster.sh
Last active December 12, 2015 10:39
Script that starts a local RabbitMQ cluster, tested with 2.7, 2.8 and 3.0
#!/bin/bash
# Usage: clusterctl start|stop
#
# Launches a local RabbitMQ cluster
#
# The name returned by `hostname -s` must resolve to 127.0.0.1
CLUSTER_SIZE=4
NODENAME_PREFIX='rmq'
@border
border / mgoExample.go
Created August 27, 2012 15:33
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@scosman
scosman / gist:2499922
Created April 26, 2012 14:22
Threaded delayed_job
# Threaded delayed_job. Useful for Heroku where each process/dyno costs money.
# run "rake jobs:threaded_work[4]" to start 4 worker threads
namespace :jobs do
desc "Start several delayed_job workers."
task :threaded_work, [:num_workers] => :environment do |t,args|
args.with_defaults(:num_workers => 1)
threads = []
workers = []
workersSemaphore = Mutex.new
@cjus
cjus / jsonval.sh
Created June 26, 2011 17:42
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')