Skip to content

Instantly share code, notes, and snippets.

@alex-leonhardt
alex-leonhardt / main.go
Last active March 9, 2024 04:23
golang text/template with a map[string]interface{} populated from mixed json data
package main
import (
"encoding/json"
"os"
"reflect"
"text/template"
)
@Radiergummi
Radiergummi / Cryptor.php
Last active March 3, 2023 13:11
A PHP class to encrypt and decrypt strings using a static application secret. Input is converted to hex strings to enable easier handling
<?php
namespace Vendor\Library;
use function bin2hex;
use function hex2bin;
use function openssl_decrypt;
use function openssl_encrypt;
use function random_bytes;
#!/bin/bash
# Перекодирует рекурсивно в текущем каталоге имена
# файлов и каталогов в транслит.
#
# Источник: http://www.ubuntu.sumy.ua/2011/03/translit.html
shopt -s nullglob
for NAME in * ; do
TRS=`echo $NAME | sed "y/абвгдезийклмнопрстуфхцы/abvgdezijklmnoprstufxcy/"`
TRS=`echo $TRS | sed "y/АБВГДЕЗИЙКЛМНОПРСТУФХЦЫ/ABVGDEZIJKLMNOPRSTUFXCY/"`
@Changaco
Changaco / btrfs-undelete
Last active April 22, 2024 20:06
btrfs-undelete
#!/bin/bash
# btrfs-undelete
# Copyright (C) 2013 Jörg Walter <info@syntax-k.de>
# This program is free software; you can redistribute it and/or modify it under
# the term of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or any later version.
if [ ! -b "$1" -o -z "$2" -o -z "$3" ]; then
echo "Usage: $0 <dev> <file/dir> <dest>" 1>&2
echo
@inso
inso / Nginx redirect to named location
Last active February 27, 2024 17:46 — forked from ilguzin/nginx_redirect_2named_location
NGINX: Redirect from current location into named location
# Solution 1
# Use only codes greater than 418, do not use common status codes 404, 402, 403, etc
location /location1 {
error_page 463 = @app; return 463;
}
# Solution 2 (drawbacks unknown)
location /location2 {
try_files /dev/null @app;
}
@jherax
jherax / clone.js
Last active May 30, 2020 15:42
Clones or extends an object (deep copy) supporting objects with circular references
/**
* @author
* David Rivera (jherax)
* https://github.com/jherax
*/
/* eslint-disable no-bitwise */
/** @private */
const toString = Object.prototype.toString;
@Vestride
Vestride / encoding-video.md
Last active April 24, 2024 09:59
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
; (function (global, define) { define('module-name', function (require, exports, module) {
// CommonJS style code here
/*!
* UMD/AMD/Global context Module Loader wrapper
* based off https://gist.github.com/tejacques/202a8f2d198ddd54a409
*
* This wrapper will try to use a module loader with the
* following priority:
*
@yuval-a
yuval-a / js-micro.js
Last active January 7, 2024 18:38
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@duzun
duzun / jq.fn.$each.js
Last active August 29, 2015 14:09
4-10 times faster jQuery.fn.each() replacement
/**
* 4-10 times faster .each replacement
* use it carefully, as it overrides jQuery context of element on each iteration
*
* function clb(DOM, idx, $DOM, DOM) {};
* $DOM == $(DOM), is the same object throughout iteration
*
*/
;(function (global) {