Skip to content

Instantly share code, notes, and snippets.

View joshisa's full-sized avatar
🎯
Focusing

Sanjay Joshi joshisa

🎯
Focusing
View GitHub Profile
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@joshisa
joshisa / posts.js
Last active September 24, 2016 10:48 — forked from glennblock/posts.js
Embedded gist syntax for Ghost. Place in ./core/server/api/posts.js.
//the code below will embed replace [gist id=x] tags with an embedded gist similar to the way the Wordpress Gist
//plugin works. I wrote this in order to import posts from Wordpress. See //GB: for the changes.
//SPJ: Updated for compatibility with Ghost 0.6.4
/**
* ### Read
* Find a post, by ID, UUID, or Slug
*
* @public
* @param {{id_or_slug (required), context, status, include, ...}} options
@joshisa
joshisa / useful_pandas_snippets.py
Last active August 31, 2015 20:44 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
val sparkConf = new SparkConf().setMaster("local").setAppName("text")
val sc = new SparkContext(sparkConf)
val hadoopConf = sc.hadoopConfiguration
//set the aws secret information
hadoopConf.set("fs.s3.impl", "org.apache.hadoop.fs.s3native.NativeS3FileSystem")
hadoopConf.set("fs.s3n.awsAccessKeyId","youraccesskeyid")
hadoopConf.set("fs.s3n.awsSecretAccessKey","secretkey")
@joshisa
joshisa / clean.docker.registry.sh
Created February 11, 2018 22:49 — forked from mohamed-el-habib/clean.docker.registry.sh
bash script to delete images from docker registry using search keyword
#!/bin/bash
#
# usage ./clean.docker.registry.sh registryUrl login filterString
#
# read the password
echo -n Password:
read -s password
user="$2:${password}"
@joshisa
joshisa / connect2beam
Created March 5, 2018 16:58 — forked from hcs42/connect2beam
connect2beam: a script that finds Erlang nodes and connect to them
#!/usr/bin/python
# connect2beam is a script that finds Erlang nodes and connects to them or
# kills them.
#
# Example for connection:
#
# $ connect2beam
# Available nodes: index name (cookie, pid)
#
@joshisa
joshisa / gist:627c0c57bb87840d59c6c63760079fa0
Created May 30, 2018 13:40 — forked from danrigsby/gist:8346b842d1446628de5223b600668dca
Copy kubernetes secrets between namespaces
kubectl get secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create -f -
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
#!/bin/bash
# Scale DOWN all Turbonetes PODs to 0
function turbo_stop_all_pods {
turbo_stop_all_pods=$(kubectl get deploy -n turbonomic --no-headers=true | cut -d ' ' -f1 | xargs -I % kubectl scale --replicas=0 deployment/% -n turbonomic)
while true; do
if `kubectl get pods -n turbonomic | grep -v STATUS | wc -l` -gt 0 then
echo -e "turbo_STOP_all_pods: Waiting on Turbonetes POD(s) to TERMINATE, so far: \n`kubectl get pods -n turbonomic | grep -v NAME`"
elif
[[ "$counter" -gt 30 ]]; then;
echo "MAX Counter Reached! One or more PODs are stuck ##TERMINATING##, intervening to kill it/them"
@joshisa
joshisa / README.md
Created March 5, 2020 17:34 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")