Skip to content

Instantly share code, notes, and snippets.

View bblanchon's full-sized avatar
🌟
No more counting dollars we’ll be counting stars

Benoît Blanchon bblanchon

🌟
No more counting dollars we’ll be counting stars
View GitHub Profile
@bblanchon
bblanchon / Openweathermap.ino
Last active August 29, 2015 13:56
Test ArduinoJsonParser with openweathermap.org
char* json = "{\"coord\":{\"lon\":-0.13,\"lat\":51.51},\"sys\":{\"message\":0.0045,\"country\":\"GB\",\"sunrise\":1393397445,\"sunset\":1393436151},\"weather\":[{\"id\":802,\"main\":\"Clouds\",\"description\":\"scattered clouds\",\"icon\":\"03d\"}],\"base\":\"cmc stations\",\"main\":{\"temp\":283.27,\"pressure\":1014,\"humidity\":61,\"temp_min\":280.93,\"temp_max\":286.48},\"wind\":{\"speed\":5.7,\"deg\":270},\"clouds\":{\"all\":40},\"dt\":1393414204,\"id\":2643743,\"name\":\"London\",\"cod\":200}";
JsonParser<80> parser;
JsonHashTable root = parser.parseHashTable(json);
Serial.print("City = ");
Serial.println(root.getString("name"));
Serial.print("Weather = ");
@bblanchon
bblanchon / ConvertCsFilesToCrlf.sh
Created February 26, 2014 13:02
Convert all *.cs files to DOS line ending (CR/LF)
find -name *.cs -exec dos2unix -A {} ;
@bblanchon
bblanchon / logrotate ghost
Last active August 29, 2015 14:01
logrotate configuration for Ghost service
# /etc/logrotate.d/ghost
/var/log/ghost.log {
rotate 12
monthly
compress
prerotate
service ghost stop
endscript
postrotate
@bblanchon
bblanchon / git-stats.sh
Last active August 29, 2015 14:03
GIT: build a CSV with the number of file vs time
#!/bin/bash
OUTPUT=stats.csv
[ -f $OUTPUT ] || echo "date;sln;proj;cs;cpp" > $OUTPUT
count() {
git ls-tree -r --name-only $COMMIT | grep -e $1 | wc -l | sed 's/ //g'
}
@bblanchon
bblanchon / ArduinoJson2.ino
Last active January 4, 2020 15:36
Comparision of JSON parsing libraries for Arduino
#include <JsonParser.h>
using namespace ArduinoJson::Parser;
char json[] = "{\"sensor\":\"outdoor\",\"value\":25.6}";
void setup()
{
Serial.begin(9600);
Serial.println(json);
@bblanchon
bblanchon / ArduinoJson2.ino
Last active August 29, 2015 14:03
Comparison of JSON encoding libraries for Arduino
#include <JsonGenerator.h>
using namespace ArduinoJson::Generator;
void setup()
{
Serial.begin(9600);
char sensor[] = "outdoor";
float value = 25.6;
@bblanchon
bblanchon / ArduinoJsonTypesSize.ino
Last active August 29, 2015 14:03
Size of types of the Arduino JSON library
#include <ArduinoJson.h>
using namespace ArduinoJson;
#define PRINT_VALUE(X) {Serial.print(#X" =\t");Serial.println(X);}
#define PRINT_SIZE(X) {Serial.print("sizeof("#X") =\t");Serial.println(sizeof(X));}
void setup()
{
Serial.begin(9600);
@bblanchon
bblanchon / avr-nm.bat
Created July 8, 2014 11:58
avr-nm the you can associate with .elf files
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-nm" --size-sort -C -r %1
pause
@bblanchon
bblanchon / manifest.json
Created September 14, 2014 10:12
syncfusion-ebook-links
{
"manifest_version": 2,
"name": "Syncfusion e-book links",
"description": "Replace DOWNLOAD buttons by convenient links",
"version": "1.0",
"content_scripts": [ {
"js": [ "jquery-1.11.1.min.js", "script.js" ],
"matches": [ "https://www.syncfusion.com/resources/techportal/ebooks" ]
} ]
@bblanchon
bblanchon / submodule2subtree
Created December 29, 2014 10:58
Git: converts a submodule to a subtree
#!/bin/bash
# Converts a submodule to a subtree
PREFIX=$1
set -euv
mkdir -p "/tmp/$PREFIX"
cp -R "$PREFIX" "/tmp/$PREFIX"
git rm $PREFIX