Skip to content

Instantly share code, notes, and snippets.

@slashk
slashk / Datadog Usage API Costs
Last active September 2, 2022 16:12
remove push arg
#!/bin/bash
# This script uses the Datadog API to pull down monthly costs by charge type (commit/on-demand) and product name into CSV
# run it like this (after you setup your datadog app / api keys as env variables as DD_APP_KEY and DD_API_KEY):
#
# % ./dd_monthly_cost_by_prod_charge.sh
#
# Output looks like this:
#
# product name, charge type, cost
@slashk
slashk / calico-1-6-no-ipip.yaml
Created April 23, 2017 02:36
yaml manifest to create non-ipip calico kubernetes clusters with kubeadm
# This ConfigMap is used to configure a self-hosted Calico installation.
kind: ConfigMap
apiVersion: v1
metadata:
name: calico-config
namespace: kube-system
data:
# The location of your etcd cluster. This uses the Service clusterIP
# defined below.
etcd_endpoints: "http://10.96.232.136:6666"
@slashk
slashk / chrome-tab-to-reminder.applescript
Last active March 2, 2017 18:07
Create reminder from Chrome tab
set importance to 9
tell application "Google Chrome"
set tabname to get title of active tab of window 1
set taburl to get URL of active tab of window 1
close active tab of window 1
end tell
display dialog "Job Priority" buttons {"Low", "Medium", "High"} default button 1 with icon caution with title tabname giving up after 10
-- priority : (1=High, 5=Medium, 9=Low, 0=None)
if the button returned of the result is "High" then
set importance to 1
@slashk
slashk / k8s-cluster-token-generator.go
Created March 2, 2017 17:49
k8s cluster token generator for kubeadm
package main
import (
"fmt"
"math/rand"
)
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
func RandStringBytes(n int) string {
(amd64)ubuntu@core:~$ snappy list -v
Name Date Version Developer
ubuntu-core 2016-02-25 16 ubuntu*
docker 2016-07-02 1.6.2.005 canonical*
generic-amd64 2016-02-25 1.4 canonical*
@slashk
slashk / gist:6f83b02cff880dbad2b3
Created March 25, 2015 18:57
regression in docker-machine 0.2
$ docker-machine --version
docker-machine version 0.2.0 (5575c6d)
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
builder virtualbox Running tcp://192.168.99.100:2376
dev virtualbox Stopped
$ docker-machine -D create -d virtualbox test
DEBU[0000] executing: /usr/bin/VBoxManage
DEBU[0000] STDOUT: Oracle VM VirtualBox Command Line Management Interface Version 4.3.26
(C) 2005-2015 Oracle Corporation
@slashk
slashk / color-renderlet.js
Created February 14, 2014 13:55
John's Color renderlet
var colorRenderlet = function (_chart) {
function setAttr(selection, keyName) {
selection.style("fill", function (d) {
if (d[keyName] == "Apples")
return "red";
else if (d[keyName] == "Kiwis")
return "green";
else if (d[keyName] == "Lemons")
return "yellow";
@slashk
slashk / gist:2714727
Created May 16, 2012 23:00
openstack nova resize instance
Using the v1.1/{tenant_id}/servers/{server_id}/action API call, you can change the flavor/instance type of the running instance. 
Here's an example of resizing an instance via the nova command line tool (with debug on to see the API calls).
First, create the instance:
$ nova boot --image bc6e9a0c-7ede-4c54-9f22-401dd87ec367 --flavor 1 ken
+------------------------+--------------------------------------+
| Property | Value |
@slashk
slashk / adsense_prowler.rb
Created September 3, 2010 18:58
fetches your daily and monthly adsense totals and sends them to your iphone via Prowl
#!/usr/bin/env ruby
# created by admin AT mtbcalendar D0T com on 09-02-2010.
#### CUSTOMIZE THE VARIABLES BELOW
ADSENSE_LOGIN = "ENTER YOUR ADSENSE EMAIL LOGIN HERE"
ADSENSE_PASS = "ENTER YOUR ADSENSE PASSWORD HERE"
PROWL_API_KEY = "ENTER YOUR PROWL API HERE"
### DON'T CHANGE ANYTHING BELOW HERE
# install these gems with:
<div id="mtbcalendar"></div>
<script src="http://www.mtbcalendar.com/javascripts/basicwidget.js" type="text/javascript"></script>
<script src="http://www.mtbcalendar.com/tags/norcal.json?callback=eventCallback&amp;future=1" type="text/javascript"></script>