Skip to content

Instantly share code, notes, and snippets.

@mshade
mshade / job-from-cronjob.py
Created August 9, 2019 04:03
manually trigger a kubernetes job from a cronjob with python from a pod
from kubernetes import client, config
import datetime
with open('/run/secrets/kubernetes.io/serviceaccount/namespace', 'r') as ns:
namespace = ns.read().strip()
# Reads config from in-container token / cert
config.load_incluster_config()
@eolant
eolant / Confirm.vue
Last active July 29, 2024 18:14
Vuetify Confirm Dialog component that can be used locally or globally
<template>
<v-dialog v-model="dialog" :max-width="options.width" :style="{ zIndex: options.zIndex }" @keydown.esc="cancel">
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message" class="pa-4">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="primary darken-1" text @click.native="agree">Yes</v-btn>
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active October 22, 2025 09:55
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@Jaza
Jaza / Flask-blueprint-with-imported-routes
Last active March 10, 2024 18:26
Example of how to split a Flask blueprint into multiple files, with routes in each file, and of how to register all those routes.
*
@amaudy
amaudy / reset_db.py
Created July 10, 2014 05:59
Python+psycopg2 for drop all tables of database you given.
#!/usr/bin/env python
import psycopg2
import sys
"""
Drop all tables of database you given.
"""
try:
@ibussieres
ibussieres / upgrade_pg.sh
Last active May 26, 2021 04:29
Upgrade PostgreSQL 9.1 to 9.3 on Ubuntu 12.04
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
@74togo
74togo / FloydSteinberg.html
Last active November 6, 2020 02:51
An example of the Floyd–Steinberg applied to images in Javascript.
<html>
<head>
<title>Dithering Test</title>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.getElementsByTagName("canvas")[0];
@lsauer
lsauer / tanimoto.cs
Created May 3, 2012 09:22
JavaScript implementation of Tanimoto Score / Index / Similarity from binary feature descriptors
//lsauer.com lo sauer 2012 - CC-BY-SA v3
//see also: http://www.daylight.com/dayhtml/doc/theory/theory.finger.html
//description: JavaScript/Coffescript implementation for computing TANIMOTO Coefficients
//implementation #1: parallelization amenable, map-reduce like
//heavily depending on JavaScripts's dynamic type casting model
Tanimoto = (key1, key2) ->
nfA = key1.split("").sum() or 0
nfB = key2.split("").sum() or 0
nfAB = key1.split("").map((e, i, a) ->
e & key2[i]

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: