Skip to content

Instantly share code, notes, and snippets.

@seth10
seth10 / SetDateCreatedToDateAdded.sh
Created Dec 21, 2018
A bash function to set the "Date Created" of a file to the macOS/Finder "Date Added"
View SetDateCreatedToDateAdded.sh
SetDateCreatedToDateAdded () { SetFile -d "$(date -j -f '%Y-%m-%d %H:%M:%S' "$(mdls $1 | grep -w kMDItemDateAdded | awk '{print $3,$4}')" +"%m/%d/%Y %H:%M:%S")" $1; }
@seth10
seth10 / mediaquery.html
Created Oct 20, 2017
Hide "Back to top" links when printing a page
View mediaquery.html
<p>
This is the top of the page. Pretend there is a ton of content here.
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
Here is the bottom.
Check out <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media">CSS media queries</a>.
</p>
<a href="#" class="back2top">Back to top<a>
<style>
View limitedInstantiation.py
class Motor(object):
def __init__(self):
pass
motorA = Motor()
motorB = Motor()
motorC = Motor()
motorD = Motor()
Motor.__init__ = lambda: None
del Motor
@seth10
seth10 / 14seg_minimal_example.ino
Last active Sep 8, 2017
All complete programs from watch repo
View 14seg_minimal_example.ino
//https://raw.githubusercontent.com/seth10/watch/31f9083a07451147009f5e92a93645e02fa69217/14seg/14seg.ino
#include "Adafruit_LEDBackpack.h"
char *message = " Hello world! ";
Adafruit_AlphaNum4 alpha4;
void setup() {
alpha4.begin();
@seth10
seth10 / 00-MoistureCSV.py
Created Aug 1, 2017
A simple program to take readings for a moisture sensor on the PiStorms-GRX
View 00-MoistureCSV.py
# import some stuff we'll need
from GroveDevices import Grove_Moisture_Sensor
from PiStorms_GRX import PiStorms_GRX
import numpy as np
import time
# create a sensor (on port BAA1), the PiStorms object, and an empty list to hold the data
sensor = Grove_Moisture_Sensor("BAA1")
psm = PiStorms_GRX()
data = []
View listHistoryCommands.sh
history | awk '{ print $2; }' | sort | uniq
#
alias
br
bt
cat
cd
chmod
clear
cp
View pythonFunctionFun.py
- # Find the index of the blob with the most pixels.
- most_pixels = 0
- largest_blob = 0
- for i in range(len(blobs)):
- if blobs[i].pixels() > most_pixels:
- most_pixels = blobs[i].pixels()
- largest_blob = i
+ # Find the blob with the most pixels.
+ largest_blob = max(blobs, key=lambda b: b.pixels())
@seth10
seth10 / 11-KeyboardLEDs.py
Created Jul 10, 2017
Functional programming example on the PiStorms
View 11-KeyboardLEDs.py
from PiStorms import PiStorms
from TouchScreenInput import TouchScreenInput
from functools import partial
psm = PiStorms()
textbox = TouchScreenInput(psm.screen)
textbox.bind_led_on_func(partial(psm.led, 1, 255, 0, 0))
textbox.bind_led_off_func(partial(psm.led, 1, *[0]*3))
result = textbox.getInput()
psm.screen.showMessage(['Your answer', result['response']])
@seth10
seth10 / PiStorms_Development.sh
Last active Jun 27, 2017
A script to link files in /home/pi/PiStorms to their corresponding locations in the system
View PiStorms_Development.sh
b=`grep homefolder /usr/local/mindsensors/conf/msdev.cfg | cut -d"=" -f2 | cut -c 2-`
for f in 'MSDriver.py' 'MSBrowser.py' 'psm_shutdown' 'swarmserver' 'pistorms-diag.sh'; do sudo ln -f $b/sys/$f /usr/local/bin/$f; done
chmod +x $b/sys/swarmserver $b/sys/pistorms-diag.sh $b/programs/addresschange
for f in 'rmap.py' 'rmapcfg.py' 'scratch.py' 'PiStorms.py' 'PiStormsCom.py' 'TouchScreenInput.py' 'mindsensorsUI.py' 'MS_ILI9341.py' 'mindsensors.py' 'MsDevices.py' 'LegoDevices.py' 'swarmclient.py'; do sudo ln -f $b/sys/$f /usr/local/lib/python2.7/dist-packages/$f; done
sudo rm -rf /var/www
sudo ln -s $b/www /var/www
sudo ln -f $b/sys/msdev.cfg /usr/local/mindsensors/conf/msdev.cfg
# skipping images, art, scratch, changing ownerships... programs are still only in /home/pi/PiStorms
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do sudo ln -f $b/setup/$f /etc/init.d/$f; done
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do chmod +x $b/setup/$f; done
View OddlyValid.py
+-1
--1
-----1
+++++1
++++++++--------1
1*-+-+-+-+-+-+-+-+-+-+-+-1*-+1/+-+-+-+-+-1