This file contains 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 | |
# Thanks to https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files | |
inotifywait -m . -e create -e moved_to | | |
while read dir action file; do | |
echo "The file '$file' appeared in directory '$dir' via '$action'" | |
# do something with the file | |
done |
This file contains 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
uint8_t memcmp_idx(uint8_t *arr1, uint8_t *arr2, size_t len, size_t *diff_idx){ | |
size_t i = 0; | |
uint8_t ret = 0; | |
while(i < len) | |
{ | |
if(arr1[i] > arr2[i]) | |
{ | |
ret = 1; | |
break; |
This file contains 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
#!/usr/bin/env python | |
from tabulate import tabulate | |
import math | |
def getHexStr(num, dig): | |
return '0x{0:0{1}X}'.format(num, dig) | |
minClk=50000000.0 | |
sysClk=216000000.0 | |
#sysClk=76000000.0 |
This file contains 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
''' | |
Based on https://gist.github.com/enjalot/2904124 (in Python 2) -> quick-migrated to Python 3 | |
Usage: python server-cors | |
''' | |
import http.server as httpserver | |
class CORSHTTPRequestHandler(httpserver.SimpleHTTPRequestHandler): | |
def send_head(self): | |
"""Common code for GET and HEAD commands. |
This file contains 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/bash | |
discendingTime(){ | |
date '+%Y.%m.%d.%H.%M.%S' | |
} | |
TIME_NOW=$(discendingTime) | |
HOST=$1 | |
PORT=$2 | |
USER=$3 | |
DATABASE=$4 | |
DB_FILE=$5-${DATABASE}-${TIME_NOW} |
This file contains 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
// http://www.uel.br/projetos/matessencial/superior/calculo/cilide/cilide00.htm | |
// http://www.uel.br/projetos/matessencial/superior/calculo/cilide/cilide00.js | |
function testa_entrada(form, button) {calcula_volume(form);return;} | |
// r = raio da base do cilindro, h = altura do liquido | |
// L = comprimento do cilindro, A = área e V = volume | |
function calcula_volume(form) { | |
if(form.entrada1.value=="" || form.entrada1.value==" " || form.entrada1.value=="0" || form.entrada2.value=="" || form.entrada2.value==" " || form.entrada2.value=="0" || form.entrada3.value=="" || form.entrada3.value==" " || form.entrada3.value=="0") | |
{alert("Existe alguma medida nula. Preencha as caixas de modo correto."); | |
return; | |
} |
This file contains 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
#/usr/bin/python | |
import math | |
r = 47.5 | |
h = 23.75 # 47.5 #95.0 | |
L = 150.0 | |
if h > 2*r: | |
print "'h' nao pode ser maior que 'r'" | |
exit() | |
A_t = math.pi * math.pow(r, 2) | |
V_t = A_t * L |
This file contains 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
#!/usr/bin/python | |
def getBinStr(num, dig): | |
return format(num, '#0'+str(dig+2)+'b') | |
def getHexStr(num, dig): | |
return '0x{0:0{1}X}'.format(num, dig) |
This file contains 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/bash | |
LOGFILE_NAME=whatismyip.log | |
GATEWAY_IP=192.168.0.1 | |
IP_PAGE_URL=checkip.dyndns.org | |
LAST_IP=`curl -s ${IP_PAGE_URL} | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'` | |
echo "Initial IP: ${LAST_IP}" | |
while true |
This file contains 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/bash | |
# this scripts copies the first file modified in current folder. It was used to backup a config file generated by | |
# SW4STM32 during the OpenOCD firmware upload invocation. | |
# 'inotifywait' binary is part of 'inotify-tools' package on Ubuntu 18.04.1 LTS | |
EVT_OUTPUT=`inotifywait -e modify,create,delete -r .` | |
FILE_NAME=`echo ${EVT_OUTPUT} | sed "s/[^ ]\+\s\+[^ ]\+\s\+\([^ ]\+\)/\1/g"` | |
cp ${FILE_NAME} ${FILE_NAME}.bak |