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 / psql.sh
Created September 20, 2018 15:05
Connection to PostgreSQL from EC2 instance
PGPASSWORD="${RDS_PASSWORD}" psql -d "${RDS_DB_NAME}" -U "${RDS_USERNAME}" -h "${RDS_HOSTNAME}" -p "${RDS_PORT}"
@bblanchon
bblanchon / latest_pdfium.sh
Created July 3, 2018 07:42
Get latest branch of PDFium
git ls-remote --heads https://pdfium.googlesource.com/pdfium.git | grep -ohP 'chromium/\d+' | tail -n1
@bblanchon
bblanchon / issue746.ino
Created June 5, 2018 09:15
Unable to reproduce issue #746
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
void setup() {
// Initialize Serial port
@bblanchon
bblanchon / collect_licenses.js
Created February 21, 2018 09:37
Collect text from all licenses in package dependencies
const fs = require('fs')
const path = require('path')
var licenses = []
var node_modules = path.resolve('./frontend/node_modules')
var meta = JSON.parse(fs.readFileSync('./frontend/package.json', 'utf8'))
for( var module in meta.dependencies ) {
try {
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("-------------------------------------");
recurse();
}
void recurse()
{
char buffer[4096];
@bblanchon
bblanchon / leanpub-recovery.js
Created November 6, 2017 09:27
Leanpub: recover lost manuscript from browser cache
// Leanpub: recovering lost manuscript
// -----------------------------------
//
// I lost the whole content of my Leanpub book after switching to GitHub.
// Fortunately, the manuscript files were still on my browser local storage.
// I was able to recover the complete manuscript using the following script.
//
// If this happens to you too, follow these steps:
//
// 1. Open your browser to https://leanpub.com
@bblanchon
bblanchon / MemoryMappedFile.hpp
Created October 6, 2017 16:09
Wrapper class for memory mapped file on Windows
#pragma once
#include <experimental/filesystem>
#include <windows.h>
class MemoryMappedFile {
public:
using path = std::experimental::filesystem::path;
@bblanchon
bblanchon / emcpp41.cpp
Created June 26, 2017 16:32
Pass by value or pass by reference
#include <iostream>
struct String
{
String()
{
}
String(const String&)
@bblanchon
bblanchon / include.sh
Created May 30, 2017 11:47
POSIX shell: source another script without replacing $0
include() {
eval "$(cat "$(dirname "$0")/$1")"
}
@bblanchon
bblanchon / DeleteUnattachedDisks.ps1
Created October 18, 2016 11:43
Azure: delete all unattached disks
Get-AzureDisk | where {$_.AttachedTo -eq $null} | Remove-AzureDisk