Skip to content

Instantly share code, notes, and snippets.

View chris-schmitz's full-sized avatar
💯

Christopher Schmitz chris-schmitz

💯
View GitHub Profile
const cluster = require('cluster');
const childProcess = require('child_process');
const cpus = require('os').cpus().length;
const processes = cpus >= 2 ? cpus : 2;
if(cluster.isMaster){
console.log("Starting server processes");
for(var i = 0; i < processes; i++){
cluster.fork();
{
"name": "simplest-typescript-express",
"version": "1.0.0",
"description": "Package.json for the simplest possible typescript service",
"main": "dist/index",
"types": "dist/index",
"scripts": {
"live": "nodemon --exec .\\node_modules\\.bin\\ts-node -- src/index.ts",
"clean": "rm -rf dist/",
"build": "npm run clean && tsc",
// action shot https://i.imgur.com/kpAiXTV.gifv
#include <Adafruit_NeoPixel.h>
#define N_LEDS 60
#define PIN 8
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
@LucienLee
LucienLee / joystick
Last active December 17, 2019 14:26
Sanwa joystick on Arduino example code
//A0 = green, A1 = yellow, A2 = orange, A3 = red
#define downPin 14
#define upPin 15
#define rightPin 16
#define leftPin 17
void setup() {
Serial.begin(9600);
/**
* @author knee-cola / https://github.com/knee-cola
* Original file URL: https://gist.github.com/knee-cola/37875bc4359609b96c9f329cd2a68fa1
*
* This is a spinner/loader built for Three.js platform.
* It can be used to notify user that some resources are being loaded.
* I made it to replace pure CSS spinner, which was displayed in the
* overlay above the 3D animation, since it was slowing down WebGL
*
* How to use:
@paambaati
paambaati / launch.js
Last active May 5, 2022 05:35
Debug mocha tests using Visual Studio Code
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
@yuanqing
yuanqing / gist:87bceacedde4dbd96fab
Last active March 28, 2023 18:10
Sublime Text: Wrap Selection in Backticks
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
}
@homam
homam / AWS_S3_File_Upload.js
Created January 27, 2014 10:08
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@ericandrewlewis
ericandrewlewis / index.md
Last active November 24, 2023 14:07
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.