Skip to content

Instantly share code, notes, and snippets.

View aguynamedben's full-sized avatar

Ben Standefer aguynamedben

View GitHub Profile
@aguynamedben
aguynamedben / localStorage.js
Created August 25, 2020 16:32
Persist Redux to localStorage, with migrations (i.e. migrate off redux-persist)
View localStorage.js
// @flow
// Inspired by https://medium.com/@jrcreencia/persisting-redux-state-to-local-storage-f81eb0b90e7e
const log = console;
let firstLoad = true;
export function loadState() {
try {
const serializedState = localStorage.getItem('state');
if (!serializedState) {
@aguynamedben
aguynamedben / jsHelpers.js
Last active December 12, 2018 18:41
Get friendly OS values in Node.js
View jsHelpers.js
import log from 'electron-log';
import macosVersion from 'macos-version';
export function humanOSName() {
const platform = os.platform();
if (platform === 'darwin') {
return 'macOS';
} else if (platform === 'win') {
return 'Windows';
} else if (platform === 'linux') {
@aguynamedben
aguynamedben / README.md
Last active December 9, 2021 09:15
Setting up SQLCipher with node-sqlite3 and Electron
View README.md

Gist notes

How I got SQLCipher working with Electron on macOS:

  • First compile SQLCipher and dynamically link it to macOS' crypto libraries. Don't use OpenSSL. Zetetic (makers of SQLCipher) say that using macOS' crypto libraries is definitely going to be easiest on a Mac. Note that using SQLCipher libraries installed via Homebrew is going to seem like it works, and it will on your computer, but Homebrew's SQLCipher dynamcially links OpenSSL, so your app will crash when deployed to other computers (i.e. dynamic linking will fail at run timer because other computer wont have OpenSSL installed). So you want to dynamically link macOS crypto.
  • Then you want to rebuild node-sqlite3 with a modified binding.gyp so that the SQLCipher library is statically linked into your SQLite binding. You should end up with a binary file ./node_modules/sqlite3/lib/binding/electron-v3.0-darwin-x64/node_sqlite3.node that has libsqlcipher.a statically linked within it. The statically linked libsqlcipher.a will in-turn dynamically
@aguynamedben
aguynamedben / custom-node-sqlite3-binding.gyp
Last active October 28, 2018 21:12
Rebuilding node-sqlite3 with support for statically linked SQLCipher
View custom-node-sqlite3-binding.gyp
# This is a modified version of binding.gyp (from node-sqlite3) that allows
# SQLCipher to be *statically linked* for Electron distribution to machines that
# do not have SQLCipher development headers present. If you distribute
# node-sqlite3 with dynamically linked SQLite/SQLCipher bindings (the default),
# your app will error out at runtime on user's machines that do not have
# SQLCipher.
#
# This problem is tricky to test and catch because the app will work fine on
# your machine, because you've probably installed SQLCipher to custom-build
# node-sqlite3. To test that everything is working, package your Electron app,
View gist:fff76c542a4fbf56bc6c8af42d4070bd
### Keybase proof
I hereby claim:
* I am aguynamedben on github.
* I am aguynamedben (https://keybase.io/aguynamedben) on keybase.
* I have a public key ASDlkClWlN-6NYMMp05UIFdu-NMB3ZJ8_hC9UCl7_g0X4go
To claim this, I am signing this object:
@aguynamedben
aguynamedben / with 100k records
Last active March 7, 2018 09:08
search benchmarking
View with 100k records
ip-192-168-7-30!ben:/Users/ben/code/fuzzracer$ yarn test
yarn run v1.5.1
$ mocha -r jsdom-global/register -r babel-core/register test/setup.js test/**/*.spec.js
Benchmarking IndexStore
100000 records created in 1871ms
Indexing took 4239ms
1000 queries created in 16ms
Quality check - Displaying 10 queries with top 10 results:
@aguynamedben
aguynamedben / gist:ff2810d9a4f5e8ac3e60
Last active August 29, 2015 14:18
lock your computer
View gist:ff2810d9a4f5e8ac3e60
If you walk away from your computer and do not lock it or log off, it poses a security risk to you and the company. Someone can use your computer in an unauthorized way even if you are away for a few minutes, such as:
Send email from your account
Tamper and delete your files
Access and download Confidential data
The easiest way to prevent unauthorized access to your desktop is to lock it when you are away, because you will not shut down any program is close any files you are working on. All you have to do to get back in is enter your password and you can pick up where you left off.
If you walk away from your computer and do not lock it or log off, it poses a security risk to you and the company. Someone can use your computer in an unauthorized way even if you are away for a few minutes, such as:
Send email from your account
Tamper and delete your files
Access and download Confidential data
The easiest way to prevent unauthorized access to your desktop is to lock it when you are away, because you will not shut
@aguynamedben
aguynamedben / gist:5341501
Last active December 15, 2015 23:39
How I use Gmail
View gist:5341501
Settings > General > Maximum Page Size > Show [100] conversations per page
Go to Inbox.
Click email in bottom (oldest).
Arrow keys to read.
Choose Option 1 or 2...
View simplegeo-features-annotations.json
{
"private": true,
"annotations": {
"venue": {
"profitable": "yes",
"owner": "China Basin Ballpark Corp."
},
"building": {
"size": "extra small",
"material": "wood",
View gist:914432
"weather": {
"cloud_cover": "80%",
"conditions": "Mostly cloudy",
"dewpoint": "47F",
"forecast": {
"today": {
"conditions": "Clear",
"precipitation": "20%",
"temperature": {
"max": "58F",