Skip to content

Instantly share code, notes, and snippets.

@zioproto
zioproto / redis-delete-old-keys.py
Last active March 3, 2023 18:45
Delete Redis Stale Keys
#!/usr/bin/env python
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
# To debug code on a single key you can use this instead of the for loops:
# key = r.randomkey()
# Delete all keys not accessed since 'idletime'
for key in r.scan_iter("*"):
idle = r.object("idletime", key)
@adamwathan
adamwathan / 1-add-macros.php
Last active June 11, 2022 19:55
Multiformat Endpoints in Laravel
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use App\Http\Middleware\CaptureRequestExtension;
class AppServiceProvider extends ServiceProvider
@w3cj
w3cj / merge.js
Last active March 26, 2021 16:02
function mergeSort(arr) {
//
// If your array has a length less than 2, congratulations! It's already sorted.
if(arr.length < 2) {
return arr;
}
// Otherwise, cut your array in half, and consider the two sub-arrays separately.
var firstLength = arr.length / 2;
var firstHalf = arr.slice(0, firstLength);
console.log('firstLength', firstLength);
@haasn
haasn / about:config.md
Last active December 27, 2024 15:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.

@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active August 26, 2024 23:46
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@JeffPaine
JeffPaine / i3-cheat-sheet.md
Last active April 9, 2025 04:23
i3 Window Manager Cheat Sheet

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (alt by default)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@jordan-brough
jordan-brough / git-recent
Last active April 1, 2025 15:55
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples:
@staltz
staltz / introrx.md
Last active April 8, 2025 04:41
The introduction to Reactive Programming you've been missing
@sammdec
sammdec / alfred-stack-search.md
Last active May 19, 2020 02:47
Add StackOverflow search to Alfred

To search Stack Overflow from alfred app, simply copy and paste below into the alfred search box, when you press enter you shoudl see a dialog asking you to install this custom Search.

alfred://customsearch/Search%20StackOverflow%3A%20%7Bquery%7D/stack/utf8/noplus/http://stackoverflow.com/search?q={query}

Then to use it in alfred simply up the search box and type in stack and the question your asking.