Skip to content

Instantly share code, notes, and snippets.

View Hugoberry's full-sized avatar

Igor Cotruta Hugoberry

View GitHub Profile
@sunnyone
sunnyone / razorsample.ps1
Created April 22, 2015 15:58
Invoke RazorEngine from PowerShell
# nuget.exe install RazorEngine
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Add-Type -LiteralPath "${scriptDir}\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll"
Add-Type -LiteralPath "${scriptDir}\RazorEngine.3.4.1\lib\net45\RazorEngine.dll"
# テンプレートに渡すデータ
$array = @(1; 2; 3)
$table = @{ Name = "F#"; ShowDetail = $true; Array = $array }
@CurtHagenlocher
CurtHagenlocher / Web.ContentsCustomRetry.m
Created April 30, 2015 13:08
Demonstrates the use of a custom retry duration with Web.Contents.
let
Value.WaitFor = (producer as function, interval as function, optional count as number) as any =>
let
list = List.Generate(
() => {0, null},
(state) => state{0} <> null and (count = null or state{0} < count),
(state) => if state{1} <> null
then {null, state{1}}
else {1 + state{0}, Function.InvokeAfter(() => producer(state{0}), interval(state{0}))},
(state) => state{1})
@CurtHagenlocher
CurtHagenlocher / multipart.m
Created July 20, 2015 20:18
Using multipart/form-data with Power Query. This assumes that any files being uploaded are textual; changing this to support arbitrary binary data is possible, but wasn't interesting to me.
let
Web.MultiPartPost = (url as text, parts as record) as binary =>
let
unique = Text.NewGuid(),
boundary = "--" & unique,
crlf = "#(cr)#(lf)",
item = (name, value) =>
let
filename = Value.Metadata(value)[name]?,
contentType = Value.Metadata(value)[type]?,
@TWIAV
TWIAV / README.md
Last active January 7, 2025 21:21
D3/TopoJSON: map wit SVG Text labels

My very first exercise with TopoJSON and D3 - just a municipal map showing some basic information when you hover over the individual municipalities. Nothing really fancy, but, hey, you have got to start somewhere...

###Steps followed to create the file nlgemeenten2009.json:

Step 1. download input file gem_2009_gn3.shp from the Dutch Statistical Office: Wijk- en Buurtkaart 2009

Step 2. convert shapefile to GeoJSON with ogr2ogr:

    ogr2ogr \
 -f GeoJSON \
@gbaman
gbaman / HowToOTG.md
Last active April 8, 2026 17:09
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@drzax
drzax / .block
Last active April 4, 2025 07:20
Narrative Charts
license: mit
scrolling: true
height: 300
@gbaman
gbaman / HowToOTGFast.md
Last active June 7, 2026 20:18
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@micahstubbs
micahstubbs / .block
Last active September 13, 2018 08:49
Greenhouse Gases Sankey Particles
license: CC0-1.0
border: none
@savetheclocktower
savetheclocktower / README.md
Last active April 14, 2026 11:44
Using a rotary encoder as a volume control for the Raspberry Pi

Update on Nov 30, 2025: This Gist is nearly eight years old! These instructions worked back in 2018 for the Pi 3, but recent comments suggest that they may not be sufficient on more recent Pi models and newer versions of Raspberry Pi OS. Be advised.


Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

@zz85
zz85 / print.js
Last active June 10, 2023 19:16
Pretty Print JSON in Ascii Tree
// TODO add colors
sample = { a: { b: { c: 1, moo: [3,2,1] } }, z: 'zzzz' }
const asciitree = require('ascii-tree');
function pretty_json(v) {
console.log(JSON.stringify( v, 0, 2 ))
}