Compare commits

...

3 Commits

Author SHA1 Message Date
Alexander Popov 5538558c7c
arduino __DATE__ 2023-08-16 22:03:50 +03:00
Alexander Popov 950d9d2f20
c buffer len 2023-08-16 22:02:35 +03:00
Alexander Popov d4e2da3838
editor config updates 2023-08-16 22:01:02 +03:00
7 changed files with 49 additions and 20 deletions

View File

@ -21,7 +21,7 @@ indent_style = space
indent_size = 4
# Crystal
[{*.cr,shard.yml}]
[{*.cr,shards.yml}]
indent_style = space
indent_size = 2
@ -80,10 +80,10 @@ indent_size = 4
indent_style = tab
indent_size = 4
[~/Gambas/*]
[snipplets/code/Gambas/*]
indent_size = 2
[~/Solar2D/**]
[snipplets/projects/Solar2D**]
indent_style = unset
indent_size = unset
end_of_line = unset

View File

@ -0,0 +1,7 @@
void loop() {
Serial.println("Built: " __DATE__ " | " __TIME__);
/**
* Example show:
* Built: Aug 16 2023 | 21:42:32
*/
}

View File

@ -0,0 +1,18 @@
// Adapted from http://stackoverflow.com/questions/1765014/convert-string-from-date-into-a-time-t
// Formats __DATE__ to YYYY-MM-DD format
String ArduinoDateToDisplayDate(char const *time) {
char s_month[5];
int month, day, year;
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
sscanf(time, "%s %d %d", s_month, &day, &year);
month = (strstr(month_names, s_month)-month_names)/3;
String monthText = month < 10 ? "0" + String(month) : String(month);
String dayText = day < 10 ? "0" + String(day) : String(day);
return String(year) + "-" + monthText + "-" + dayText;
}
// https://gist.github.com/djohnson001/6df673a8d7f8ac04246a

View File

@ -1,17 +1,17 @@
#!/bin/bash
# TCP
#coproc nc -l localhost 3000
# coproc nc -l localhost 3000
# UnixSocket
coproc nc -l -U ./app.sock
while read -r cmd; do
case $cmd in
d) date ;;
q) break ;;
*) echo 'Try again?'
esac
case $cmd in
d) date ;;
q) break ;;
*) echo 'Try again?'
esac
done <&"${COPROC[0]}" >&"${COPROC[1]}"
kill "$COPROC_PID"

View File

@ -0,0 +1,4 @@
/* size_t strlen(const char *s); */
size_t length;
length = strlen("Example string");

View File

@ -6,5 +6,5 @@ files=(
for file in "${files[@]}"
do
clang-format -i --style=LLVM --sort-includes=false $file
clang-format -i --style=LLVM --sort-includes=false $file
done

View File

@ -8,24 +8,24 @@
int g = 0;
void *my_thread(void *vargp) {
int *id = (int *)vargp;
int *id = (int *)vargp;
static int s = 0;
static int s = 0;
++s;
++g;
++s;
++g;
printf("Thread ID: %d, Static: %d, Global: %d\n", *id, ++s, ++g);
printf("Thread ID: %d, Static: %d, Global: %d\n", *id, ++s, ++g);
}
int main() {
pthread_t tid;
pthread_t tid;
int i;
for (i = 0; i < 3; i++)
int i;
for (i = 0; i < 3; i++)
pthread_create(&tid, NULL, my_thread, (void *)&tid);
pthread_exit(NULL);
pthread_exit(NULL);
return 0;
return 0;
}