Skip to content

Instantly share code, notes, and snippets.

View nazt's full-sized avatar

Nat nazt

  • Chiang Mai Maker Club
  • Chiang Mai
  • X @nazt
View GitHub Profile
@nazt
nazt / image.resize.in.github.flavored.markdown.md
Created January 18, 2019 03:13 — forked from uupaa/image.resize.in.github.flavored.markdown.md
image resize in github flavored markdown.

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@nazt
nazt / thingy-server.js
Created November 2, 2018 04:53 — forked from DurandA/thingy-server.js
Thingy:52 Web Thing server using webthing-node
const {Action, Event, Property, Thing, WebThingServer} = require('./index');
const uuidv4 = require('uuid/v4');
var Thingy = require('thingy52');
var Color = require('color');
console.log('Reading Thingy environment sensors!');
class ButtonEvent extends Event {
constructor(thing, state) {
@nazt
nazt / gist:04f3b890219a00c6aff0b79c22c0b04d
Created June 30, 2018 05:05 — forked from xsleonard/gist:7341172
hex string to byte array, C
unsigned char* hexstr_to_char(const char* hexstr)
{
size_t len = strlen(hexstr);
IF_ASSERT(len % 2 != 0)
return NULL;
size_t final_len = len / 2;
unsigned char* chrs = (unsigned char*)malloc((final_len+1) * sizeof(*chrs));
for (size_t i=0, j=0; j<final_len; i+=2, j++)
chrs[j] = (hexstr[i] % 32 + 9) % 25 * 16 + (hexstr[i+1] % 32 + 9) % 25;
chrs[final_len] = '\0';
@nazt
nazt / ngrok-selfhosting-setup.md
Created June 27, 2018 04:48 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@nazt
nazt / README-setup-tunnel-as-systemd-service.md
Created March 3, 2018 02:16 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/[email protected]. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@nazt
nazt / autossh.service
Created March 3, 2018 02:12 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@nazt
nazt / wlan-monitor.sh
Created November 23, 2017 15:43 — forked from jeffskinnerbox/wlan-monitor.sh
Simple script for wireless stations monitoring
#!/bin/bash
#
# WLAN Minitoring Script Version v2.0
# OpenWrt Atheros wireless radio STA status monitor
# Developed by dir2cas <[email protected]>
#
# Comments:
# Required packages: bash, iw, kmod- packages&drivers to get your wireless interface running
# Optional packages:
# install with $ opkg update; opkg install iw bash ....
@nazt
nazt / put.sh
Last active September 19, 2017 05:48
put.sh
# V1
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1001?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd"-d 30
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1002?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd"-d 30
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1003?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd"-d 30
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1004?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd"-d 30
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1005?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd"-d 30
#for Demo version
curl -X PUT "http://api.netpie.io/topic/TraffyPatong/v/1/time/id/1007?retain&auth=tN5raLDu2VRFqS8%3Aej78ZOAB8bMqxyym1UbC8CtGd" -d 30
#include <DHT.h>
#include <ESP8266WiFi.h>
// replace with your channel's thingspeak API key,
String apiKey = "88Z86W9GHVXIDXDW";
const char* ssid = "xxxxx";
const char* password = "xxxxx";
const char* server = "api.thingspeak.com";
#define DHTPIN 12 // what pin we're connected to
#include <DHT.h>
#include <ESP8266WiFi.h>
// replace with your channel's thingspeak API key,
String apiKey = "88Z86W9GHVXIDXDW";
const char* ssid = "xxxxx";
const char* password = "xxxxx";
const char* server = "api.thingspeak.com";
#define DHTPIN 12 // what pin we're connected to