Skip to content

Instantly share code, notes, and snippets.

View bc-jasond's full-sized avatar
🏗️
hacking

Jason Dubaniewicz bc-jasond

🏗️
hacking
View GitHub Profile
@bc-jasond
bc-jasond / data-model-migration.js
Created September 2, 2019 13:50
dubaniewi.cz jsx-to-json parser
import {
BlogPost, NodeA,
NodeCode,
NodeCodeSection,
NodeContent,
NodeH1,
NodeH2, NodeImage, NodeItalic, NodeLi, NodeLink, NodeOl, NodeP, NodePostLink, NodeQuote, NodeSiteInfo,
NodeSpacer, NodeStrike,
NodeText
} from './blog-content.model.mjs';
@bc-jasond
bc-jasond / data-model-migration2.js
Created September 2, 2019 05:43
dubaniewi.cz content model migration script
// ESM - remove after ECMAScript Module support is past Experimental node v14 ?
require = require('esm')(module/*, options*/);
const {
NODE_TYPE_LI,
NODE_TYPE_P,
NODE_TYPE_A,
NODE_TYPE_BOLD,
NODE_TYPE_CODE,
NODE_TYPE_ITALIC,
NODE_TYPE_LINK,
@bc-jasond
bc-jasond / node-rails-cookie.js
Created January 23, 2018 23:04
decrypt rails 4 cookies in node
@bc-jasond
bc-jasond / killport.sh
Created January 11, 2018 19:02
killport
function killport() {
kill -kill `lsof -t -i tcp:$1`
}
export -f killport
/*
We are implementing a `view` that must consume
some external service (which we've mocked below). The service returns
data that needs to be sanitized for client consumption -- in the
below example it includes sensitive information like SSN, email, etc.... The
exercises work through simple sanitizations, to slightly more complex
ones, before asking that the interviewee try to define a general approach
to solving the problem.
*/
var _ = require('lodash');
/*
Please implement a function that compares two version numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number sequences.
For instance, 2.5 is not "two and a half" or "half way to version three", it is the fifth second-level revision of the second first-level revision.
Here is an example of version numbers ordering:
function getImportsFromFile(fileName) {
const readline = require('readline');
const fs = require('fs');
const imports = [];
return new Promise((resolve, reject) => {
const readStream = fs.createReadStream(fileName);
readStream.on('error', (err) => reject(err));
const rl = readline.createInterface({input: readStream});
@bc-jasond
bc-jasond / scroll-select.md
Last active February 17, 2016 01:59
Infinite Scroll Select with Typeahead search

Background:

Our API uses pagination on all lists. Every list endpoint returns an object like this:

{
    "count": 14,
    "next": http://stuff.com/page=2,
    "previous": null,
    "results": [...]
}
#!/bin/bash
brew install nvm
nvm
mkdir ~/.nvm
cp $(brew --prefix nvm)/nvm-exec ~/.nvm/
echo "export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh" >> $HOME/.bashrc
nvm
@bc-jasond
bc-jasond / killem.sh
Last active April 26, 2016 17:01
kill all processes named argv[1] or at prompt
#!/usr/bin/env bash
if [ -z "$1" ]
then
echo "What should I kill?"
read line
else
line="$1"
fi
arr=($(sudo ps -A | grep "$line" | cut -d' ' -f1))