Skip to content

Instantly share code, notes, and snippets.

// snippets
@ttmarek
ttmarek / cloudSettings
Last active January 31, 2020 21:46
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-01-31T21:46:49.408Z","extensionVersion":"v3.4.3"}

When it looks like Jest isn't transpiling your code.

Try deleting Jest's cached transpiled files

cd $TMPDIR && rm -r jest_dx

To Switch or Not to Switch

You know, before Redux came out I had this idea in my head that the switch statement wasn't great. I don't think I was alone in thinking that either. I was under the impression that it was "preferred" or "best practice" to use object literals instead. For whatever reason, Redux seems to have repopularized switch for better or worse.

Old habits die hard. While reading through the tire icon util, I couldn't help but think all these switch statements could be replaced by simple object

@ttmarek
ttmarek / set.js
Created March 9, 2017 04:28
A function for deeply setting values
function set(obj, path, value) {
const clone = Object.assign({}, obj);
const keys = path.split('.');
const lastKey = keys.pop();
// --------------------------------------------------
if (keys.length === 0) {
clone[lastKey] = value;
return clone;
@ttmarek
ttmarek / xcompile.cmake
Created September 28, 2015 01:33
Cross Compile Toolchain file (CEF Linux Compile to Windows Executable)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER /usr/bin/i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER /usr/bin/i686-w64-mingw32-windres)
@ttmarek
ttmarek / running_make.log
Created September 28, 2015 01:31
Console errors from running make (cross compiling CEF Linux to Windows executable)
> make -j4 cefclient cefsimple
Scanning dependencies of target libcef_dll_wrapper
Scanning dependencies of target libcef_dll_wrapper
[ 2%] [ 2%] [ 2%] Building CXX object libcef_dll/CMakeFiles/libcef_dll_wrapper.dir/base/cef_atomicops_x86_gcc.cc.obj
Building CXX object libcef_dll/CMakeFiles/libcef_dll_wrapper.dir/base/cef_bind_helpers.cc.obj
i686-w64-mingw32-g++: error: /MP: No such file or directory
i686-w64-mingw32-g++: error: /Gy: No such file or directory
i686-w64-mingw32-g++: error: /GR-: No such file or directory
i686-w64-mingw32-g++: error: /Zi: No such file or directory
i686-w64-mingw32-g++: error: /W4: No such file or directory
@ttmarek
ttmarek / running_cmake.log
Created September 28, 2015 01:30
Console output from running cmake on the Chromium Embedded Framework (cross compile Linux to Windows)
> cmake -G "Unix Makefiles" -D CMAKE_TOOLCHAIN_FILE=xcompile.cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++ -- works
@ttmarek
ttmarek / arduino_serial.py
Created May 2, 2014 21:30
Python script to read serial data from the Arduino
import serial
import csv
import re
import matplotlib.pyplot as plt
import pandas as pd
portPath = "/dev/ttyACM0" # Must match value shown on Arduino IDE
baud = 115200 # Must match Arduino baud rate
timeout = 5 # Seconds
filename = "data.csv"
@ttmarek
ttmarek / TakeReading.ino
Created May 2, 2014 21:29
Function to send serial data to a computer, for use with FunctionGenerator.ino
/* takeReading function
* takes in an analaog pin number as an integer
* sends serial data to PC to be read by Python
*/
void takeReading(int pinNum)
{
Serial.print(seconds,4);
Serial.print(',');
Serial.println(analogRead(pinNum));
}