Skip to content

Instantly share code, notes, and snippets.

@smola
smola / k8s-jprofiler-attach.sh
Created March 23, 2018 14:49
Attach JProfiler agent to a JVM running in a Kubernetes pod
#!/bin/bash
set -e
if [[ -z ${K8S_JVM_POD} ]]; then
echo "K8S_JVM_POD not defined"
exit 1
fi
EXEC="kubectl exec ${K8S_JVM_POD}"
CP="kubectl cp ${K8S_JVM_POD}"
@audy
audy / example.md
Last active February 6, 2021 17:02
Get Rscript to print line numbers when errors occur

Get Rscript to print line numbers when errors occur

Put this at the top of your executable Rscript file:

options(error = quote({
  dump.frames(to.file=T, dumpto='last.dump')
  load('last.dump.rda')
  print(last.dump)
 q()
@pkuczynski
pkuczynski / parse_yaml.sh
Last active April 9, 2024 18:36
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@andrewgiessel
andrewgiessel / gist:5684769
Created May 31, 2013 12:52
fit a sigmoid curve, python, scipy
# good discussion here: http://stackoverflow.com/questions/4308168/sigmoidal-regression-with-scipy-numpy-python-etc
# curve_fit() example from here: http://permalink.gmane.org/gmane.comp.python.scientific.user/26238
# other sigmoid functions here: http://en.wikipedia.org/wiki/Sigmoid_function
import numpy as np
import pylab
from scipy.optimize import curve_fit
def sigmoid(x, x0, k):
y = 1 / (1 + np.exp(-k*(x-x0)))
@mbostock
mbostock / .block
Last active October 20, 2023 14:09
General Update Pattern, I
license: gpl-3.0
redirect: https://observablehq.com/@d3/selection-join
@leipzig
leipzig / mycd.sh
Created January 21, 2012 03:36
directory based history bash profile
function mycd()
{
#if this directory is writable then write to directory-based history file
#otherwise write history in the usual home-based history file
tmpDir=$PWD
echo "#"`date '+%s'` >> $HISTFILE
echo $USER' has exited '$PWD' for '$@ >> $HISTFILE
builtin cd "$@" # do actual cd
if [ -w $PWD ]; then export HISTFILE="$PWD/.dir_bash_history"; touch $HISTFILE; chmod --silent 777 $HISTFILE;
else export HISTFILE="$HOME/.bash_history";
@naaman
naaman / delete-heroku-apps.sh
Last active March 5, 2021 20:57
[WARNING THIS WILL HARD DELETE YOUR APPS. YOU COULD LOSE DATA. MAKE SURE YOU KNOW WHAT YOURE DOING!!!!!!!!!!] Delete all heroku apps from bash terminal -- no script file required
for app in $(heroku apps); do heroku apps:destroy --app $app --confirm $app; done
@brantfaircloth
brantfaircloth / sphinx_to_github.sh
Created January 23, 2011 02:40
Sphinx documentation to github gh-pages without submodules
# assume the following directory structure where contents of doc/
# and source/ are already checked into repo., with the exception
# of the _build directory (i,e. you can check in _themes or _sources
# or whatever else).
#
# proj/
# source/
# doc/
# remove doc/_build/html if present
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then