Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
cd ~
sudo apt-get update
sudo apt-get install netatalk git python-dev python-pip python-rpi.gpio -y
sudo pip install Flask
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
cd ..
git clone https://github.com/mirhec/raspi-http-switch.git
@mirhec
mirhec / IniFile.cs
Last active February 13, 2017 12:37
IniFile implementation based on the original Windows P/Invoke, grabbed from http://stackoverflow.com/a/14906422/4112816
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
internal class IniFile // revision 11
{
readonly string _path;
readonly string _exe = Assembly.GetExecutingAssembly().GetName().Name;
@mirhec
mirhec / Ini.cs
Last active February 13, 2017 14:15 — forked from Larry57/ini.cs
A single class to read and write INI files.
using System;
using System.Collections.Generic;
using System.Linq;
internal class Ini
{
private readonly Dictionary<string, Dictionary<string, string>> _ini = new Dictionary<string, Dictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
private string CurrentSection { get; set; } = "";
public Ini(string iniContents)
@mirhec
mirhec / get-pip.py
Created March 24, 2017 09:37
get-pip.py clone from 2017-03-24
This file has been truncated, but you can view the full file.
#!/usr/bin/env python
#
# Hi There!
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip.
#
# Pip is a thing that installs packages, pip itself is a package that someone
# might want to install, especially if they're looking to run this get-pip.py
2017/05/24 13:55:15 Serving [::]:3000 with pid 3734
[Macaron] 2017-05-24 13:55:17: Started GET /SIMON-IBV/QMT/releases for [::1]
[Macaron] PANIC: runtime error: slice bounds out of range
/usr/local/go/src/runtime/panic.go:489 (0x433b4)
gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/runtime/panic.go:35 (0x42204)
panicslice: panic(sliceError)
/home/git/src/code.gitea.io/gitea/vendor/code.gitea.io/git/repo_tag.go:136 (0x3519e0)
parseTag: next := strings.IndexByte(left[end+2:], ' ')
/home/git/src/code.gitea.io/gitea/vendor/code.gitea.io/git/repo_tag.go:164 (0x351bf4)
@mirhec
mirhec / nginxproxy-docker-compose.yml
Created September 28, 2017 11:24
The nginx-proxy docker-compose file I'm using to host my websites
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
@mirhec
mirhec / setup-mosquitto-raspi.md
Created October 2, 2017 14:40
Setup mosquitto broker on raspberry pi with openhab

Install Mosquitto on Raspberry Pi with OpenHAB

Install a raspberry pi with the latest OpenHABian version.

Install Mosquitto

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key

cd /etc/apt/sources.list.d/

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
###################################################################################################
#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
#### except in compliance with the License. A copy of the License is located at
####
#### http://aws.amazon.com/apache2.0/
####
#### or in the "license" file accompanying this file. This file is distributed on an "AS IS"
#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
extern crate structopt;
extern crate ini;
use structopt::StructOpt;
use std::path::{Path, PathBuf};
use ini::Ini;
use std::fs::{self, DirEntry};
#[derive(StructOpt, Debug)]
#[structopt(name = "type-cli")]