Skip to content

Instantly share code, notes, and snippets.

@arjunKumbakkara
arjunKumbakkara / Migrate Keys from One Redis DB to Another Redis DB
Last active January 16, 2020 10:40
Beautiful and Painful Redis Cluster Migration
#set connection data accordingly
#Will only work for redis > 5.0
#Easiest way
#if it doesnt work , then try with target_db=0 for both
#Also always use -c after redis-cli . Or else the redirection wont work and it will throw (error) Move
#There are multiple ways of doing it. One is via MIGRATE command , 2nd is via DUMP and RESTORE command.
source_host=localhost
source_port=6379
@reecelucas
reecelucas / useScrollDirection.js
Last active September 8, 2021 20:07
React hook to detect scroll direction, based on the API of https://github.com/dollarshaveclub/scrolldir
const SCROLL_UP = "up";
const SCROLL_DOWN = "down";
const useScrollDirection = ({
initialDirection,
thresholdPixels,
off
} = {}) => {
const [scrollDir, setScrollDir] = useState(initialDirection);
@dieppon
dieppon / currency_symbols.php
Last active February 13, 2023 15:46 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '&#1380;',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',
@juris
juris / redis-cluster-backup.sh
Last active March 21, 2023 14:27
Redis Cluster backup script
#!/bin/sh
readonly cluster_topology=$(redis-cli -h redis-cluster cluster nodes)
readonly slaves=$(echo "${cluster_topology}" | grep slave | cut -d' ' -f2,4 | tr ' ' ',')
readonly backup_dir="/opt/redis-backup"
mkdir -p ${backup_dir}
for slave in ${slaves}; do
master_id=$(echo "${slave}" | cut -d',' -f2)
@inecmc
inecmc / notes.md
Created August 4, 2017 08:06
How to run multiple Redis instances on Ubuntu 16.04

Create the directory for the new instance

$ sudo install -o redis -g redis -d /var/lib/redis2

Create a new configuration file

$ sudo cp -p /etc/redis/redis.conf /etc/redis/redis2.conf
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@ericelliott
ericelliott / defaults-overrides.md
Last active May 7, 2023 13:52
ES6 defaults / overrides pattern

ES6 Defaults / Overrides Pattern

Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.

function foo ({
    bar = 'no',
    baz = 'works!'
  } = {}) {
@sebmarkbage
sebmarkbage / react-terminology.md
Last active January 9, 2023 22:47
React (Virtual) DOM Terminology
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@kohnmd
kohnmd / hdpicanvas.js
Created April 13, 2014 17:28
Scale canvas element for high DPI monitors.
/**
* Resizes the canvas for high DPI (retina) screens.
*
* Modified from here: http://www.html5rocks.com/en/tutorials/canvas/hidpi/
*
* By Paul Lewis, customized by Mike Kohn
*/
var HDPICanvas = (function() {
function scale(canvas) {