Skip to content

Instantly share code, notes, and snippets.

@m-radzikowski
m-radzikowski / script-template.sh
Last active Dec 1, 2021
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@tyhenry
tyhenry / list-of-addons-git.sh
Last active Dec 4, 2020
list ofxAddons for OF project, with git repo / version info > 'addons.git.make'
View list-of-addons-git.sh
#!/bin/bash
# list-of-addons-git.sh
#
# to be run inside of an openFrameworks project with 'addons.make' file.
# writes 'addons.git.make' - list addons and git repo urls, branches, and commits to 'addons.git.make' file
INPUT="addons.make" # addons list file
OUTPUT="addons.git.make" # output file
@madskjeldgaard
madskjeldgaard / gen_pat_file.scd
Last active Mar 9, 2020
Generative SuperCollider files containing random patterns
View gen_pat_file.scd
/*
Generate SuperCollider file containing simple random pattern
*/
(
// Time stamp
~stamp = Date.getDate.stamp;
// This goes in the duration key of the pattern
~dur = "Pseq(%)".format(Array.rand(10, 0.1,10.0));
@kawsark
kawsark / Vault-ssh-ca-README.md
Created Mar 28, 2019
A guide for configuring Vault's SSH-CA
View Vault-ssh-ca-README.md

SSH CA use-case with Vault

In this scenario we are going to set up Vault to sign SSH keys using an internal CA. We will configure the SSH secrets engine and create a CA within Vault. We will then configure an SSH server to trust the CA key we just created. Finally we will attempt to SSH using a private key, and a public key signed by Vault SSH CA.

Prerequisites

  • This guide assumes you have already provisioned a Vault server, SSH host using OpenSSH server, and a SSH client machine.
  • The client system must be able to reach the Vault server and the OpenSSH server.
  • We will refer to these systems respectively as:
    • VAULT_SERVER
View darkify_slack.sh
#!/bin/sh
# Darkify Slack on Mac OS or Linux.
# curl https://gist.githubusercontent.com/ryanpcmcquen/8a7ddc72460eca0dc1f2dc389674dde1/raw/darkify_slack.sh | sh
if [ "`uname -s`" = "Darwin" ]; then
SLACK_INTEROP_JS="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
else
SLACK_INTEROP_JS="/usr/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
fi
@KrabCode
KrabCode / src_MainApp.java
Last active Nov 27, 2018
Tessellated spheres source in IntelliJ IDEA - to run this in the vanilla Processing IDE just remove everything that mentions MainApp including the "class MainApp extends PApplet" part and you're golden - also you'll need the PostFX and PeasyCam libraries found in Tools -> Add tool.
View src_MainApp.java
import ch.bildspur.postfx.builder.PostFX;
import peasy.PeasyCam;
import processing.core.PApplet;
import processing.core.PShape;
import processing.core.PVector;
import processing.opengl.PShader;
import java.util.ArrayList;
public class MainApp extends PApplet {
View squareZoom.pde
// zooming squares. by dave
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
View squaresCircles.pde
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@larvel
larvel / migrateserver.sh
Created Sep 24, 2018
Script to copy production server to test server
View migrateserver.sh
#!/bin/bash
USER=user
MYSQLPASSWORD=password
MYSQL="/usr/bin/mysql"
MYSQLDUMP="mysqldump --max_allowed_packet=800M"
TESTSERVER=mynewserver.mydomain.com
FOLDER=/usr/local/atlassian/
EXCLUDE="--exclude *.pid --exclude backup/*.zip --exclude atlassian-confluence.log* --exclude catalina.*.log --exclude localhost.*.log --exclude updateTestServer.sh* --exclude daily-backup-* --exclude backup-*.zip --exclude atlassian-jira.log.* --exclude catalina.out --exclude *confluencedata/index* --exclude *confluencedata/backups/* --exclude *prosjektwiki/confluencedata/backups/* --exclude *old/"
@bookjan
bookjan / face-detection.py
Last active Aug 19, 2021
Using python opencv to detect face and send the frames to FFmpeg to create HLS(HTTP Live Streaming)
View face-detection.py
import numpy as np
import cv2
import sys
cap = cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier('<PATH_TO_CASCADES_FOLDER>/haarcascade_frontalface_default.xml')
while(True):
# Capture frame-by-frame