Skip to content

Instantly share code, notes, and snippets.

@dontfreakout
dontfreakout / tggl-track-ceil.js
Created June 27, 2023 14:32 — forked from Gaspadlo/tggl-track-ceil.js
Toggle Track week overview logs ceiling rounder - rounds dangling seconds to full minutes (JS bookmarklet script)
javascript: window.sleepFn = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
window.processingLog = false;
window.processedLogs = 0;
clearInterval(window.roundingInterval);
window.visibleTogglEvents = Array.from(document.querySelectorAll(".rbc-event"));
window.visibleTogglEventsCount = window.visibleTogglEvents.length;
window.roundingInterval = setInterval(async () => {
if (window.processingLog) {
return;
}
@dontfreakout
dontfreakout / create-vod-hls.sh
Created July 6, 2021 13:53 — forked from maitrungduc1410/create-vod-hls.sh
Bash scripts to create VOD HLS stream with ffmpeg (Extended version)
#!/usr/bin/env bash
LC_NUMERIC="en_US.UTF-8"
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# comment/add lines here to control which renditions would be created
@dontfreakout
dontfreakout / .bashrc
Created January 22, 2020 16:39
Shell shortcuts for Homestead or any Vagrant box
function homestead() {
( cd ~/Homestead && vagrant $* )
}
export -f homestead
## SSH to box and cd to same directory as current dir on local machine. If machine is offline, start it up before ssh to it
function homessh() {
if homestead status --machine-readable | grep state,running > /dev/null 2>&1; then
@dontfreakout
dontfreakout / SimpleReorderTrait.php
Created October 15, 2018 15:28
Trait which allow use only order column to reorder items in Laravel Backpack.
<?php
namespace App\Http\Controllers\Admin\Contracts;
/**
* Instead of "Nested Set pattern" use only "order" column to reorder the items in the database.
* Database columns needed: id, name, order
*
* @return
*/
trait SimpleReorderTrait
@dontfreakout
dontfreakout / htaccess
Created April 6, 2016 21:51
Htaccess Leverage Browser Caching
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 hour"
@dontfreakout
dontfreakout / htpasswd.py
Created February 2, 2016 12:26 — forked from guerrerocarlos/htpasswd.py
Python script for generating htaccess passwords
#!/usr/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@dontfreakout
dontfreakout / sh_env_var_opts.sh
Created January 22, 2016 10:51 — forked from KylePDavis/sh_env_var_opts.sh
Simple bash shell script templates. There are two versions: 1) simple env var based options, and 2) with added command line argument parsing and error handling.
#!/bin/bash -e
# A SHORT DESCRIPTION OF YOUR SCRIPT GOES HERE
# USAGE:
# DESCRIPTION OF ENV VARS HERE
###############################################################################
set -e # exit on command errors (so you MUST handle exit codes properly!)
set -o pipefail # capture fail exit codes in piped commands
#set -x # execution tracing debug messages
# Get command info
@dontfreakout
dontfreakout / 90-logitech-marble.conf
Created December 2, 2015 09:55
Logitech - Trackman Marble Trackball Linux X.Org configuration. Copy to /etc/X11/xorg.conf.d/90-logitech-marble.conf
Section "InputClass"
Identifier "Marble Mouse"
MatchProduct "Logitech USB Trackball"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "SendCoreEvents" "true"
Option "Buttons" "9"
Option "ButtonMapping" "1 8 3 4 5 6 7 2 9"
@dontfreakout
dontfreakout / file_put_contents_atomic.php
Created November 11, 2015 16:16
PHP Atomic file put content
function file_put_contents_atomic($filename, $content) {
$temp = tempnam(FILE_PUT_CONTENTS_ATOMIC_TEMP, 'temp');
if (!($f = @fopen($temp, 'wb'))) {
$temp = FILE_PUT_CONTENTS_ATOMIC_TEMP . DIRECTORY_SEPARATOR . uniqid('temp');
if (!($f = @fopen($temp, 'wb'))) {
trigger_error("file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING);
return false;
}
}
// Takes [count] of items and the [partition] (array of percentages) to
// distribute against. Returns an array of integers that sums to [count]:
// an integer composition weighted by the partition.
//
// We don't use the Bresenham algorithm because it doesn't provide the best
// results for low values of [count].
function DISTRIBUTE(count, partition) {
// Custom function in Apps Script takes a 2D array. We're only interested in
// the first row.
partition = partition[0];