Skip to content

Instantly share code, notes, and snippets.

@threeel
threeel / Leaderboard Using Redis
Created July 3, 2025 20:40 — forked from wonjun27/Leaderboard Using Redis
Leaderboard Using Redis
Leaderboard Using Redis
http://labs.strava.com/blog/koms-powered-by-redis/
Strava KOMS, Powered by Redis
----------------
http://aimeeault.com/2014/06/22/making-the-most-of-redis-and-sorted-sets/
For example, what if I only want to see a leaderboard of members who are between the ages of 18 and 49? The Sorted Set contains no information on how old each member is. And I don’t want to maintain a separate Redis Sorted Set for just these users, because that’s kind of redundant, right? You probably don’t want to fetch every single one of the potentially hundreds of thousands of records and filter individually… that’s not very efficient! There’s a couple of ways you could approach this with Redis. One is by way of Lua scripting with use of EVAL (which runs Lua) and ZSCAN (which can be used for matching keys and values by rules, similar to regular expressions).
@threeel
threeel / Sony WH-1000XM4.md
Created December 19, 2024 07:43 — forked from peters/Sony WH-1000XM4.md
Connecting Sony WH-1000XM4 to Ubuntu 22.04 (Jammy)

Connecting Sony WH-1000XM4 to Ubuntu 22.04 (Jammy)

This guide will help you connect your Sony WH-1000XM4 headset to Ubuntu 22.04 using Bluetooth. Once connected, you'll be able to listen to music and use the microphone on apps like Microsoft Teams.

1. Connect to Bluetooth Headset

Steps:

  1. Open a terminal and launch bluetoothctl:
@threeel
threeel / AppName.php
Created August 18, 2022 14:16 — forked from isluewell/AppName.php
[6.0] Command app:name
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Composer;
use Symfony\Component\Finder\Finder;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
@threeel
threeel / listen.py
Created November 29, 2021 11:40 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@threeel
threeel / Lravel-5-inpalce-edit-using-xeditable.php
Created February 25, 2018 23:24 — forked from pupadupa/Lravel-5-inpalce-edit-using-xeditable.php
Laravel 5 inplace editing using jquery's x-editable plugin . Inline and bulk editing examples.
/**
*
* In this example we create view with inplace and bulk editing.
* Tools and plugins:
* jQuery
* xEditable jquery plugin
* twitter bootstrap
*
*/
@threeel
threeel / 0_reuse_code.js
Created August 5, 2017 16:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@threeel
threeel / rewrite-links.php
Created June 12, 2017 09:33 — forked from taylorotwell/rewrite-links.php
Rewriting Links
@threeel
threeel / mesos-on-ubuntu.md
Created May 29, 2017 13:54 — forked from EronWright/mesos-on-ubuntu.md
Setup Mesos on Ubuntu 16 (Dev Setup)

Configure Mesos

These instructions are derived from those in the Mesos Community Documentation.

Do the below as root.

Install

cat <<EOF >> /etc/apt/sources.list.d/mesosphere.list
deb http://repos.mesosphere.com/ubuntu xenial main
@threeel
threeel / weather.sh
Last active February 16, 2017 16:44 — forked from taylorotwell/weather.sh
Weather CLI
alias weather='curl -s wttr.in | sed -n "1,7p"'
alias weather-long="curl -s wttr.in | sed -n '1,38p'" #long weather.. all data
alias weather-today="curl -s wttr.in | sed -n '1,17p'" #weather today
alias weather-tomorrow="curl -s wttr.in | sed -n '1,7p'" #weather tomorrow
@threeel
threeel / LogAfterRequest.php
Created December 21, 2016 15:31 — forked from Shelob9/LogAfterRequest.php
Log all request to Laravel app. Based on http://blog.phakeapps.com/2015/06/23/log-every-request-and-response-in-laravel-5/ updated for Laravel 5.3
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Log;
class LogAfterRequest {
public function handle($request, \Closure $next)
{
return $next($request);
}