Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / aes-256-gcm.go
Last active September 2, 2021 00:52 — forked from tinti/aes-256-gcm.go
[golang aes-256-gcm] Example script using AES-256 in golang #go #crypto
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"flag"
"fmt"
"io"
@goliatone
goliatone / mysql-docker.sh
Created April 24, 2019 22:47 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@goliatone
goliatone / client.go
Created April 16, 2019 04:57 — forked from Merovius/client.go
Dbus minimal example in go, rudimentary implementation of http://www.galago-project.org/specs/notification/0.9/
package main
import (
"github.com/guelfey/go.dbus"
)
func main() {
conn, err := dbus.SessionBus()
if err != nil {
panic(err)
@goliatone
goliatone / avahi.go
Created March 26, 2019 20:09 — forked from lemenkov/avahi.go
How to register service with Avahi using golang and dbus
package main
import (
"github.com/guelfey/go.dbus"
"log"
"bufio"
"os"
)
func main() {
@goliatone
goliatone / mh-z14.ino
Created January 26, 2019 05:42 — forked from igrr/mh-z14.ino
MH-Z14 ESP8266 Arduino example
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <time.h>
const char* ssid = "co2_sensor";
const char* password = "1qazxsw2";
ESP8266WebServer server(80);
@goliatone
goliatone / Makefile
Created December 2, 2018 02:28 — forked from TheHippo/Makefile
Golang Makefile example
OUT := binariy-name
PKG := gitlab.com/group/project
VERSION := $(shell git describe --always --long --dirty)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/)
all: run
server:
go build -i -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG}
@goliatone
goliatone / Router.swift
Created September 17, 2018 02:37 — forked from zmeyc/Router.swift
Router pattern in Swift
// Playing with router pattern in Swift. Paste to a playground.
//
// This code is in public domain, feel free to copy/paste.
import Cocoa
extension NSScanner {
func scanUpToString(string: String) -> String? {
var result: NSString? = nil
if scanUpToString(string, intoString: &result) {
@goliatone
goliatone / LICENSE
Created August 9, 2018 18:26 — forked from kirbysayshi/LICENSE
Hierarchical Spatial Hash Grid: extremely efficient spatial hashing for collision detection between objects of any size! This is an implementation in JS as described in http://www10.informatik.uni-erlangen.de/~schornbaum/hierarchical_hash_grids.pdf
Copyright 2012 Andrew Petersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@goliatone
goliatone / gist:19271d6bba18ea49f4c3b7ba83a000df
Created July 16, 2018 05:14 — forked from cprovatas/gist:6acef442fc43123bcd5d5e937dc7951a
Monitor Mouse Event for any arbitrary application on macOS in Swift
let callback: CGEventTapCallBack = { (tapProxy, eventType, event, refcon) -> Unmanaged<CGEvent>? in
debugPrint("we are monitoring the mouse event here")
return nil
}
let eventMask = (1 << CGEventType.leftMouseDown.rawValue) | (1 << CGEventType.leftMouseUp.rawValue)
let machPort = CGEvent.tapCreateForPid(pid: 40529, place: .tailAppendEventTap, options: .defaultTap, eventsOfInterest: CGEventMask(eventMask), callback: callback, userInfo: nil)!
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, machPort, 0)
@goliatone
goliatone / esp8266_pubsubclient.ino
Created July 3, 2018 16:01 — forked from igrr/esp8266_pubsubclient.ino
PubSubClient sample for ESP8266 Arduino
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
const char* ssid = ".................";
const char* password = "................";
char* topic = "esp8266_arduino_out";
char* server = "iot.eclipse.org";