Skip to content

Instantly share code, notes, and snippets.

@mirhec
mirhec / markdown-import.php
Created April 21, 2021 21:00 — forked from vlucas/markdown-import.php
Imports Markdown files in a local directory into a WordPress installation
<?php
// Turn on all error reporting so we can see if anything goes wrong
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
// Relative path to your wp-config.php file (to connect to the database)
require '../wp-config.php';
require './frontmatter.php'; // Parses YAML frontmatter - https://github.com/Modularr/YAML-FrontMatter
require './Parsedown.php'; // Markdown parser - https://github.com/erusev/parsedown
import click
import os
import glob
from configparser import ConfigParser
import re
@click.group()
def cli():
pass
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")]
###################################################################################################
#### 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

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.
@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/

@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 / raspi-setup-gitea.md
Created September 20, 2017 07:14
Installing Gitea on Raspberry Pi with nginx, SSL and automatic backups

Setup Gitea on Raspberry Pi (3)

These instructions are based on this article: https://www.alexruf.net/2016/05/23/setup-gogs-git-service.html.

Setup Raspberry Pi with minimal Raspbian image. You need to connect to the HDMI port and set the following:

sudo raspi-config

There you need to enable the SSH server and you should change the hostname.

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 / 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