Skip to content

Instantly share code, notes, and snippets.

@arelra
arelra / dcr-puppeteer.js
Created July 12, 2023 15:54
dcr-puppeteer.js
const puppeteer = require("puppeteer");
const fs = require("fs");
const breakpoints = {
mobile: [320, 768],
mobileMedium: 375,
mobileLandscape: 480,
phablet: 660,
tablet: 740,
desktop: 980,
const input = Deno.readTextFileSync("./input.txt");
const priority = (code: number) =>
code < 97 ? code - 38 : code - 96;
const findDuplicate = (first: string, second: string, third: string) => {
const map = new Map();
const update = (c, mask) => map.set(c, (map.get(c) ?? 0) | mask);
first.split('').map((c) => update(c, 0x001));
second.split('').map((c) => update(c, 0x010));
third.split('').map((c) => update(c, 0x100));
return ([...map].find(([k,v]) => v === 0x111))[0];
const targets = ['cj', 'dl', 'ei', 'jk', 'rl', 'sa', 'sb'];
const bullet = Math.floor(Math.random() * targets.length);
const shot = targets[bullet];
console.log(shot);
@arelra
arelra / git-stuff.sh
Last active July 1, 2022 14:46
Git stuff
# list all remotes
git remote -v
# delete a remote
git remote remove repoalias
# push a repo to another repo
git remote add newrepo git@...
git push newrepo main
git subtree push --prefix dist origin gh-pages
@arelra
arelra / launch.json
Created January 5, 2022 17:23
VSCode launch.json for Jest using package.json configuration
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest watch current file",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"${fileBasename}",
@arelra
arelra / gist:72ffe82f5f47d3b327c8fbb0d2740be9
Created January 22, 2017 17:03
macosx-bash-largest-files
find . -type f -print0 | xargs -0 ls -l | sort -k5,5rn > ~/files.txt
aws s3 ls s3:// | awk '{ count +=1; size += $3 } END { print "Count:", count, "Size:", size, "bytes" }'
@arelra
arelra / gist:9e9a5387b9cb33cdecb3
Last active September 21, 2015 22:40
s3-to-xmlstarlet-to-json-to-elasticsearch
#!/bin/bash
while read -r line
do
printf "attempting: $line > "
tmpfile=./tmp/$line.xml
aws s3 cp s3://*****/$line $tmpfile > /dev/null
if grep -q "<???????:para>" $tmpfile; then
printf "ABSTRACT: Y > "
xmlstarlet sel -t -o "{ @@@@id@@@@ : @@@@" -v "//?????:eid" -o "@@@@, @@@@abstract@@@@ : @@@@" -t -v "//abstract/?????" -o "@@@@}" $tmpfile > $tmpfile.json
sed -i -e 's/"/\\"/g' $tmpfile.json
@arelra
arelra / diffsoutput
Created April 15, 2015 22:09
Diff output diffs only
diff file1 file2 | awk '{if ( $2 != "") print $2}'