Skip to content

Instantly share code, notes, and snippets.

View benlongo's full-sized avatar

Ben Longo benlongo

  • VALIS Insights, Inc.
  • Boston, MA
View GitHub Profile
@jboner
jboner / latency.txt
Last active July 25, 2024 11:30
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@azadisaryev
azadisaryev / convertExcel2Sheets
Last active March 9, 2024 18:23
Google Apps Script for converting Excel (.xls or .xlsx) file to Google Spreadsheet. Drive API must be enabled in your script's Advanced Google Services and in Developers Console for the script to work (see https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services for details).
/**
* Convert Excel file to Sheets
* @param {Blob} excelFile The Excel file blob data; Required
* @param {String} filename File name on uploading drive; Required
* @param {Array} arrParents Array of folder ids to put converted file in; Optional, will default to Drive root folder
* @return {Spreadsheet} Converted Google Spreadsheet instance
**/
function convertExcel2Sheets(excelFile, filename, arrParents) {
var parents = arrParents || []; // check if optional arrParents argument was provided, default to empty array if not
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active July 12, 2024 11:15
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@cjorssen
cjorssen / jiles-atherton.py
Created January 31, 2016 20:46
A crude implementation of jiles-atherton model based on http://physics.stackexchange.com/a/72789/10757
import numpy as np
from matplotlib import pyplot as plt
mu0 = 4 * np.pi * 1e-7 # H/m
a = 470 # A/m
alpha = 9.38e-4
c = 0.0889
k = 483 # A/m
Ms = 1.48e6 # A/m
@zbyte64
zbyte64 / sample.py
Created June 27, 2016 23:00
Docker py put archive example
import tarfile
import time
from io import BytesIO
admin_password = 'xxxxx'
#write password to file
pw_tarstream = BytesIO()
pw_tar = tarfile.TarFile(fileobj=pw_tarstream, mode='w')
file_data = admin_password.encode('utf8')
@jlauemoeller
jlauemoeller / phoenix-and-vue-with-brunch.md
Last active July 14, 2020 21:25
Setting up a Basic Phoenix+Vue+Brunch project

Work in Progress: Phoenix + Vue + Brunch

This documents how I integrate Vue 2.0 with Phoenix 1.x using the default brunch pipeline.

The toolchain

Start out by adding the vue-brunch plugin. You will need a version later than 1.2.3 in order to be able to use the extractCSS option (see later). At the time of writing, 1.2.3 was still the version fetched by npm so I suggest just getting the tip of the dev branch for now (this branch is for Vue 2.0 compatibility anyway):

npm install git+https://github.com/nblackburn/vue-brunch.git#dev --save-dev
@mterwill
mterwill / USAGE.md
Last active February 16, 2024 09:23
Beancount importers, scripts, etc.

Note: everything here is pretty specific to my usage/accounts and not written for public use... You'll probably have to tweak a bunch of stuff.

$ bean-extract config.py ~/Downloads # the csvs should be in here
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@svet-b
svet-b / snapd_on_moxa.md
Last active October 7, 2022 05:36
Running snapd and snaps on a Moxa UC-8100 board

The Moxa UC-8100 line of "industrial IoT gateways", such as the Moxa UC-8112-LX, can be a good solution for on-site data acquisition. To get the most out of them we want to enable them to run snaps, like https://snapcraft.io/ammp-edge. Unfortunately, as of writing, the latest v2.0 firmware provided with these devices does not support this, for two main reasons:

  1. The pre-installed OS is Debian 8, while snapd requires at least Debian 9.
  2. The stock kernel does not include SquashFS support, and does not have the required CONFIG_DEVPTS_MULTIPLE_INSTANCES option set.

The steps for rectifying these shortcomings are roughly as follows:

Compiling and installing a custom kernel

The following commands assume you're doing this on the Moxa device itself, though for more expedient results you'll want to cross-compile on something more powerful. Also note that in order to build the kernel you'll need a couple of GB of free space, which is more

@mulbc
mulbc / ceph-client.rb
Last active May 6, 2020 03:36
ceph client library CLI tools for OSX
class CephClient < Formula
desc "Rados and RBD CLIs and libraries of the Ceph project"
homepage "https://ceph.com"
url "git@github.com:ceph/ceph.git", :using => :git, :tag => "v13.2.0"
sha256 "9469c2af0a997a27ddfced71cef3fd55483ab0e34cc36a07a46ccf0d886a2d91"
depends_on :python if MacOS.version <= :snow_leopard
depends_on :osxfuse
depends_on "openssl" => :build