Skip to content

Instantly share code, notes, and snippets.

for n in {1..100} ; do
output=''
expr $n % 3 > /dev/null || output='fizz'
expr $n % 5 > /dev/null || output=$output'buzz'
[ -z $output ] && output=$n
echo $output
done
import jsonstreams
with jsonstreams.Stream(jsonstreams.Type.object, filename='foo') as my_file:
my_dict = {
'Name': 'Pants',
'Color': 'khaki',
}
for k, v in my_dict.iteritems():
my_file.write(k, v)
with my_file.subobject('Folders') as sub:
"speeduino 201903: Speeduino 2019.03"
"Capture Date: Mon May 20 19:07:49 PDT 2019"
Time SecL RPM MAP MAPxRPM TPS AFR Lambda IAT CLT Engine DFCO Gego Gair Gbattery Gwarm Gammae Accel Enrich VE PW AFR Target PW2 DutyCycle1 DutyCycle2 TPS DOT Advance Dwell Battery V rpm/s Error # Error ID Boost PSI Boost cut Launch Hard Hard Limiter IAC value Baro Pressure Sync Loss # AuxIn CH0 AuxIn CH1 AuxIn CH2 AuxIn CH3 AuxIn CH4 AuxIn CH5 AuxIn CH6 AuxIn CH7
sec rpm kpa % O2 bits % % % % % % % ms O2 ms %/s deg ms V rpm/s None kpa
0.000 30 0 101 0 0 20.000 1.361 21 82 0 0 100 100 109 100 109 100 6 0.0 13.500 0.0 0.0 0.0 0 5 5.5 11.4 0 2 0 0.0 0 0 0 0 101 0 0 0 0 0 0 0 0 0
0.008 30 0 101 0 0 20.000 1.361 21 82 0 0 100 100 109 100 109 100 6 0.0 13.500 0.0 0.0 0.0 0 5 5.5 11.4 0 2 0 0.0 0 0 0 0 101 0 0 0 0 0 0 0 0 0
0.062 30 0 101 0 0 20.000 1.361 21 82 0 0 100 100 109 100 109 100 6 0.0 13.500 0.0 0.0 0.0 0 5 5.5 11.4 0 2 0 0.0 0 0 0 0 101 0 0 0 0 0 0 0 0 0
0.120 31 0 101 0 0 20.000 1.361 21 82 0 0 100 10
@johnxx
johnxx / 2019-05-20_18.56.12.csv
Created May 21, 2019 01:58
Cranking 2019-05-20 18:56 PDT
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 8. in line 1.
#
PriLevel,SecLevel,Trigger,Sync,RefTime,MaxTime,ToothTime,Time
Flag,Flag,Flag,Flag,ms,ms,ms,ms
1.0,0.0,0.0,1.0,33.104,461.38,-428.276,33.104
0.0,0.0,0.0,1.0,41.484,461.38,8.38,41.484
1.0,0.0,0.0,1.0,82.708,461.38,41.224,82.708
0.0,0.0,0.0,1.0,88.512,461.38,5.804,88.512
1.0,0.0,0.0,1.0,103.092,461.38,14.58,103.092
0.0,0.0,0.0,1.0,107.836,461.38,4.744,107.836
1.0,0.0,0.0,1.0,119.892,461.38,12.056,119.892
@johnxx
johnxx / Speeduino Tune 2018-11-12.msq
Created November 12, 2018 20:41
Current Speeduino tune for 1996 Subaru Impreza (no start)
<?xml version="1.0" encoding="ISO-8859-1"?>
<msq xmlns="http://www.msefi.com/:msq">
<bibliography author="TunerStudio MS 3.0.28 - EFI Analytics, Inc." tuneComment="" writeDate="Mon Nov 12 11:55:37 PST 2018"/>
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2018.9-dev" nPages="10" signature="speeduino 201809-dev"/>
<page>
<pcVariable name="tsCanId">"CAN ID 0"</pcVariable>
<pcVariable cols="1" digits="0" name="algorithmLimits" rows="8">
511.0
100.0
511.0
diff --git a/ardustim/ISRs.cpp b/ardustim/ISRs.cpp
index 813dc3e..c4a722e 100644
--- a/ardustim/ISRs.cpp
+++ b/ardustim/ISRs.cpp
@@ -79,6 +79,7 @@ wheels Wheels[MAX_WHEELS] = {
{ oddfire_vr_friendly_name, oddfire_vr, 0.2, 24 },
{ optispark_lt1_friendly_name, optispark_lt1, 3.0, 720 },
{ twelve_minus_three_friendly_name, twelve_minus_three, 0.4, 48 },
+ { subaru_six_seven_name_friendly_name, subaru_six_seven, 3.0, 720 },
{ thirty_six_minus_two_two_two_friendly_name, thirty_six_minus_two_two_two, 0.6, 72 },
@johnxx
johnxx / 2018-11-02_01.26.02.csv
Last active November 3, 2018 07:50
Composite Log 2018-11-02
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 6. in line 2.
#Firmware: Speeduino 2018.9-dev
MARK 000
0.0,0.0,0.0,1.0,NaN,63.688
1.0,0.0,0.0,1.0,36.436,100.124
0.0,0.0,0.0,1.0,10.896,111.02
0.0,1.0,1.0,1.0,19.508,130.528
0.0,0.0,1.0,1.0,9.108,139.636
1.0,0.0,0.0,1.0,35.228,174.864
0.0,0.0,0.0,1.0,8.0,182.864
@johnxx
johnxx / cssgrep.sh
Created August 24, 2018 21:01
Use html-xml-utils like grep with CSS selectors
#!/bin/bash
if ! which hxselect > /dev/null; then
echo You need hxselect and hxnormalize
echo Run this: sudo apt-get install html-xml-utils
exit 1
fi
hxselect="hxselect -s \n -i"
hxnormalize="hxnormalize -l 10000000 -x "
@johnxx
johnxx / wider-than.sh
Created May 6, 2016 18:05
Links pictures over a certain width (and ratio) to a new directory
#!/bin/sh
[ $1 != '' ] || exit 1
source=$1
width=$2
IFS='
'
debug=1
mkdir -p $width
for n in $(find $source -type f -regextype posix-egrep \
-regex '.*.(png|jpg|jpeg|gif)') ; do