Skip to content

Instantly share code, notes, and snippets.

@idettman
idettman / multithreading-que.md
Last active October 29, 2025 04:52
Python Multithreading: Queues

Python Multithreading and Queues

A queue is similar to a list:

from Queue import Queue

my_list = []
my_list.append(1)
my_list.append(2)
@idettman
idettman / parpipeline.js
Created March 7, 2020 08:07
JavaScript Parallel Pipeline API
var ParallelPipeline = (function() {
var { objectType, ArrayType, Any } = TypedObject;
function fromFunc(shape0, func, grainType) {
var shape = [];
if ((shape0 | 0) === shape0)
shape.push(shape0 | 0);
else {
for (var i = 0; i < shape0.length; i++) {
if ((shape0[i] | 0) !== shape0[0])
@idettman
idettman / cookie-utils.js
Created March 7, 2020 07:15
JavaScript Cookie Utils
@idettman
idettman / pikathreading.py
Last active February 28, 2020 02:56
python pika threading example
def receive_command():
print("ENTERED")
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
print("1")
channel = connection.channel()
print("2")
channel.exchange_declare(exchange='STORE_CMD', type='topic')
print("3")
result = channel.queue_declare(exclusive=True)
print("4")
@idettman
idettman / bash.md
Last active October 29, 2025 04:51
cheatsheets

title: Bash scripting keywords:

  • Variables
  • Functions
  • Interpolation
  • Brace expansions
  • Loops
  • Conditional execution
  • Command substitution
@idettman
idettman / .editorconfig
Last active February 26, 2020 09:03
Example .editorconfig, .eslintrc, package.json, and .gitignore
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@idettman
idettman / download-and-run-gist.js
Created January 14, 2020 04:42
Download and run gist JS
(function downloadAndRunCodeSnippet() {
// form rawGit proxy url
var ghUrl = 'bahmutov/code-snippets/master/first-paint.js';
var rawUrl = 'https://rawgit.com/' + ghUrl;
// download and run the script
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = rawUrl;
head.appendChild(script);
function stringSize(str) {
// JavaScript strings are unicode UTF-16 up to 2 bytes per character
return str.length * 2;
}
function objectSize(obj) {
return stringSize(JSON.stringify(obj));
}
var value = function value(key) {
@idettman
idettman / jsdoc-external-function-example.js
Created December 9, 2019 08:54
JSDoc external function example
// my-new-type.js
/**
* MyNewType definition
* @typedef {MyNewType} MyNewType
* @param {number} first
* @param {number} second
* @property {function} logFirst
* @property {function} logSecond
* @returns MyNewType
*/
@idettman
idettman / jsdoc-exports-example.js
Created December 9, 2019 08:15
JSDoc exports example
'use strict';
/**
* Creates an instance of the StatusCodeErrorItem
* @memberof common
* @constructor
* @classdesc A class for holding information about an error. The params object allows the tracking of the function
* parameters that caused the error, but should not be used to store large objects.
* @description Creates an instance of the StatusCodeErrorItem with the given message and optional params object
* @param {string} message The message for this error