Skip to content

Instantly share code, notes, and snippets.

cwd=`pwd`;cd /usr/local; curl -s https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.gz | sudo tar --strip-components 1 -xz && cd "$cwd"
@sparkida
sparkida / pickle-helper.py
Created August 28, 2019 14:51
Pickle Gzip helper for Jupyter Notebook
"""
Helper to Pickle objects with bz2 compression
"""
import bz2, pickle, os.path
def save_object(filename, data_object):
print('saving object "' + filename + '"')
save_file = bz2.BZ2File(filename, 'w')
pickle.dump(data_object, save_file)
@sparkida
sparkida / slow-properties.js
Last active December 10, 2018 22:55
Fast Properties pt 2
'use strict';
let v8 = require('v8');
let start = Date.now();
let fieldMap = {};
let amount = 2E5;
let cycles = 4;
for (let c = 0; c < cycles; c++) {
fieldMap['a_'+c] = 'a'+c;
fieldMap['b_'+c] = 'b_'+c;
fieldMap['c_'+c] = 'c'+c;
@sparkida
sparkida / fast-properties.js
Last active December 10, 2018 22:54
Fast Properties pt 1
'use strict';
let v8 = require('v8');
let start = Date.now();
let fieldMap = {};
let amount = 2E5;
let cycles = 4;
for (let c = 0; c < cycles; c++) {
fieldMap['a_'+c] = 'a'+c;
fieldMap['b_'+c] = 'b_'+c;
fieldMap['c_'+c] = 'c'+c;
@sparkida
sparkida / codename.iterm
Created September 19, 2018 00:34
iTerm2 conf
{
"Use Non-ASCII Font" : false,
"Tags" : [
],
"Ansi 12 Color" : {
"Green Component" : 0.6151015758514404,
"Blue Component" : 0.9642278552055359,
"Red Component" : 0.3451849222183228
},
@sparkida
sparkida / eslint.rc
Last active July 16, 2018 16:44
Eslint basic setup
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
],
"env": {
"es6": true,
"browser": true,
"node": true,
},
@sparkida
sparkida / vimForceUnixFormat
Last active March 29, 2018 10:32
First, find all files in current directory with the extension ".php" and remove all "^M" ^M = Ctrl+V + Ctrl+M (don't just type the caret "^" symbol and M...they are not the same :/ )
#!/bin/bash
#Find and replace all files with ^M (dos format) to Unix format.
find $(pwd) -type f -name "*.php" | while read file; do sed -e 's/^M//g' -i "$file"; done;
@sparkida
sparkida / dlog
Created August 25, 2017 12:54
Truncate/Flush docker logs
#!/usr/bin/env bash
containerName='';
truncateDockerLog(){
truncate -s 0 $(docker inspect $containerName | grep log | awk '{print $2}' | cut -d\" -f2)
}
# pass no args and truncate all
# pass a container name and truncate that container
@sparkida
sparkida / stat
Created August 26, 2017 20:25
netstat socket status
#!/usr/bin/env bash
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n
@sparkida
sparkida / crep
Last active August 23, 2017 16:28
clean grep console.log (Node.js)
#!/bin/bash
grep -R console.log --exclude-dir node_modules --exclude-dir .git --exclude *.md .