This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| struct ret | |
| { | |
| char *id; | |
| int accel_x; | |
| int accel_y; | |
| int accel_z; | |
| int gyro_x; | |
| int gyro_y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int byteCmp (byte a[], byte b[], int n) { | |
| for (byte i = 0; i < n; i++) { | |
| if (a[i] != b[i]) { | |
| return 1; | |
| } | |
| } | |
| return 0; | |
| } | |
| // somewhere in loop()... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .... | |
| WHERE timestamp | |
| BETWEEN | |
| strftime('%s', ?, 'unixepoch', 'start of day') | |
| AND | |
| strftime('%s', ?, 'unixepoch', 'start of day', '+1 days', '-1 second') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import subprocess | |
| #device_re = "Bus \d{,3} Device \d{,3}: ID ([a-f0-9]+:[a-f0-9]+)" | |
| device_re = "ID ([a-f0-9]+:[a-f0-9]+)" | |
| df = subprocess.check_output("lsusb", shell=True) | |
| for i in df.split('\n'): | |
| if i: | |
| print (re.findall(device_re, i, re.I)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| struct list { | |
| int v; | |
| struct list *next; | |
| }; | |
| void reverse (struct list **head) { | |
| struct list *p, *n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # f [targets]... | |
| # process targets, reads targets from stdin if no arguments are supplied | |
| f() { | |
| if [ $# = 0 ] | |
| then | |
| while read -r t | |
| do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| while getopts "ab-:" opt | |
| do | |
| case "${opt}" in | |
| -) | |
| case "${OPTARG}" in | |
| foo) echo foo;; | |
| bar) echo bar;; | |
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/bin/sh | |
| # the redirections are a bit confusing, but trust me it works | |
| # progress_gpio.sh (change at your discretion) should read integers representing | |
| # percentage progress and manipulate the leds accordingly | |
| dd if="/dev/sda" | pv -EEn 2>&1 > out.img | progress_gpio.sh | |
| # out.img should be a raw dump of the disk, but i'd recommend also | |
| # saving an fdisk -l "/dev/sda". You could also compress the image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?", RUN+="/usr/local/bin/autoclone.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package sumsuffix | |
| func SumSuffix (s string) int { | |
| var r int | |
| for i := 0; i < len(s); i++ { | |
| suffix := s[i:] | |
| for j := 0; j < len(suffix); j++ { | |
| if s[j] != suffix[j] { | |
| break | |
| } |