Skip to content

Instantly share code, notes, and snippets.

@neftaly
neftaly / cyberpunk2077-ssh.md
Created June 10, 2019 03:36
Cyberpunk 2077 internal-cdprojektred.com SSH session
neftaly@nef-w10:~$ ssh [email protected] -p 2020
[email protected]'s password:
WhenItsReady

 ___________  ____________ _____   ___ _____ _   _______  ______ ___________
/  __ \  _  \ | ___ \ ___ \  _  | |_  |  ___| | / /_   _| | ___ \  ___|  _  \
| /  \/ | | | | |_/ / |_/ / | | |   | | |__ | |/ /  | |   | |_/ / |__ | | | |
| |   | | | | |  __/|    /| | | |   | |  __||    \  | |   |    /|  __|| | | |
| \__/\ |/ /  | |   | |\ \\ \_/ /\__/ / |___| |\  \ | |   | |\ \| |___| |/ /
#include <FastLED.h>
#define DATA_PIN 5
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 480
CRGB leds[NUM_LEDS];
int pos = 0;
@neftaly
neftaly / i3-laptop
Last active February 22, 2021 03:36
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
@neftaly
neftaly / ddb-backup-parse.js
Created January 16, 2018 01:24
DynamoDB backup (v3) raw file to/from JSON
const R = require('ramda');
const typeEncoder = (mode, type) => {
if (mode !== 'fromDynamo' && mode !== 'toDynamo') {
throw new Error('Invalid mode: ' + mode);
}
const numberEncoder = mode === 'fromDynamo' ? Number : String;
switch (R.toUpper(type)) {
case 'S': return String;
case 'N': return numberEncoder;
// Split an array every time the predicate returns true
// :: f => (array -> Boolean) -> f a -> f a
const segment = R.curry((fn, array) => {
const chunks = [];
let chunk = [];
for (let value of array) {
if (fn(value)) {
chunks.push(chunk);
chunk = [];
}
@neftaly
neftaly / dynamo.js
Last active September 12, 2016 04:28
Convert DynamoDB <-> JS
import R from 'ramda';
/*
Convert JS maps to/from DynamoDB maps.
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.ResponseFormat
*/
// Convert DynamoDB data to/from JS data
// :: => 'fromDynamo' => dynamoType => dynamoValue => jsValue
// :: => 'toDynamo' => dynamoType => jsValue => dynamoValue
const uuid = () => { // Create a secure V4 UUID
const randomHexChars = qty => crypto
.randomBytes(Math.ceil(qty / 2))
.toString('hex')
.slice(0, qty);
const reserved = ['8', '9', 'a', 'b'][crypto.randomBytes(1)[0] % 4];
return [
randomHexChars(8),
randomHexChars(4),
'4' + randomHexChars(3),
@neftaly
neftaly / mapwhile.js
Created April 10, 2016 15:00
mapWhile - cancellable map function
import R from "ramda";
const mapWhile = R.curry((
predicate, // while fn - receives current partial list & value, returns bool
transformation, // map fn
list // source list
) => R.reduce((oldAcc, oldVal) => {
const newVal = transformation(oldVal);
const newAcc = [ ...oldAcc, newVal ];
return predicate(newAcc, newVal) ? newAcc : R.reduced(oldAcc);
@neftaly
neftaly / pptToMap.js
Last active May 17, 2017 00:12
parent pointer tree to map
import R from "ramda";
const stringize = value => typeof value === "number" ? value + "" : value;
const orphanIds = R.compose(
R.reduce((partial, pair) => [
...partial,
pair[0],
...orphanIds(pair[1].children)
], []),
@neftaly
neftaly / btssearch.js
Last active November 30, 2015 14:22
Binary search on time-series database
// inst: unix epoch
const hist = {
"channel1": [
{ inst: 10000, id: "a" },
{ inst: 20000, id: "b" },
{ inst: 30000, id: "c" },
{ inst: 30000, id: "d" },
{ inst: 40000, id: "e" }
]
};