Skip to content

Instantly share code, notes, and snippets.

@VasekPurchart
VasekPurchart / .bashrc
Last active July 8, 2023 18:29
GIT global configuration and enhancements
# used by Git (commit messages, rebase, ...)
export EDITOR=vim
@slevithan
slevithan / xregexp-lookbehind2.js
Created April 14, 2012 21:06
Simulating lookbehind in JavaScript (take 2)
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp.
// Captures within lookbehind are not included in match results. Lazy
// repetition in lookbehind may lead to unexpected results.
(function (XRegExp) {
function prepareLb(lb) {
// Allow mode modifier before lookbehind
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb);
return {
@jooray
jooray / yt-whisper
Created February 5, 2023 21:09
A script to download an audio from a video from a streaming platform such as youtube and transcribe it to text using whisper.cpp
#!/bin/bash
# Usage: yt-whisper URL [OUTPUT_FILENAME_TEMPLATE [LANGUAGE]]
# If OUTPUT_FILENAME_TEMPLATE is empty, output is yt-whisper-video
# If LANGAUGE is empty, it is set to "auto"
# General settings (paths) for whisper.cpp
# Note - this uses whisper.cpp, not official whisper. Get it at
# https://github.com/ggerganov/whisper.cpp
# You will have to adjust these
@guillemcanal
guillemcanal / docker-alpine-iconv.md
Created August 9, 2016 13:03
Build the PHP 5 iconv extension from source for Alpine

Build PHP5 iconv extension from source for Alpine

If you plan to use iconv() to transliterate string in you PHP project, please, take this:

FROM alpine:3.4

RUN apk add --update php5-cli wget build-base php5-dev autoconf re2c libtool \
@tzmfreedom
tzmfreedom / pg_notify.php
Last active March 8, 2023 23:09
postgresql notify/listen sample
<?php
$db = new PDO(
"pgsql:dbname=postgres host=localhost port=5432", 'postgres', 'postgres', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]
);
$db->exec('LISTEN hoge');
@polaskj
polaskj / deploy.sh
Last active October 27, 2022 10:20 — forked from dfetterman/lambda_function-ECS-cloudwatch-slack.py
Lambda function that takes ECS Cloudwatch events and sends a notification to Slack
#!/bin/bash
# deploy serverless stack
serverless deploy \
--stage "dev" \
--region "us-east-1" \
--service-name "my-service-name" \
--slack-channel "#slack-alerts-example" \
--webhook-url "https://hooks.slack.com/services/12345/12345/abcdefg" \
--ecs-cluster-arn "arn:aws:ecs:us-east-1:123456:cluster/test-cluster"
@JanTvrdik
JanTvrdik / .bashrc
Last active June 14, 2022 04:14 — forked from gsomoza/.bashrc
ssh-agent support for Git Bash / MinGW / msys / Windows
# put this in ~/.bashrc
export SSH_AUTH_SOCK=/tmp/.ssh-socket
ssh-add -l > /dev/null
if [ $? = 2 ]; then
rm -f $SSH_AUTH_SOCK
echo Starting new ssh-agent...
eval $(ssh-agent -a $SSH_AUTH_SOCK) > /dev/null
ssh-add && echo "ssh-agent set up successfully with the following keys:" && ssh-add -l
fi
@ilg-ul
ilg-ul / bash-inits.sh
Last active April 19, 2022 13:24
BASH recommended initialisation sequence
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
@piotrplenik
piotrplenik / docker
Created March 24, 2017 09:00
Turn on Docker Remote API on Ubuntu (on port 2375)
# File: etc/default/docker
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS=""
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
@JakubTesarek
JakubTesarek / .bashrc
Last active October 27, 2021 19:59
.bashrc file with useful shortcuts. The file can update itself using `updaterc`. Also contains detection of platform it's running on
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
# Detect platform
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
platform='freebsd'