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 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 / 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
@bblanchon
bblanchon / VisualStudio for Python 2.7.reg
Created February 17, 2015 14:23
VisualStudio for Python 2.7, also work with distutils
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC]
"ProductDir"="C:\\Users\\azuretools\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0"
@bblanchon
bblanchon / upgrade-teamcity.sh
Created March 16, 2015 10:45
Automatically upgrade TeamCity server
#!/usr/bin/bash
set -eu
trap "tput sgr0" 0
echo -n "Enter new TeamCity version: "
read VERSION
FILE=TeamCity-$VERSION.tar.gz