Skip to content

Instantly share code, notes, and snippets.

View slaveofcode's full-sized avatar
🎯
Debugging

Aditya Kresna slaveofcode

🎯
Debugging
View GitHub Profile
@slaveofcode
slaveofcode / rsa.go
Created April 9, 2024 01:38 — forked from sohamkamani/rsa.go
Example of RSA encryption, decryption, signing, and verification in Go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
)
@slaveofcode
slaveofcode / go-build-all
Created September 18, 2022 11:08 — forked from eduncan911/go-build-all
Go Cross-Compile Script
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
@slaveofcode
slaveofcode / nsqd.service
Created May 18, 2021 17:43 — forked from a-r-g-v/nsqd.service
nsqd, nsqdlookupd systemd service files
[Unit]
Description=NSQD
After=network.target
[Service]
WorkingDirectory=/usr/local/nsq
ExecStart=/usr/local/nsq/bin/nsqd -http-address 127.0.0.1:4151 -tcp-address 127.0.0.1:4150 -lookupd-tcp-address 127.0.0.1:4160
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
KillMode=process
@slaveofcode
slaveofcode / conditional.sh
Created April 20, 2021 04:14
if conditions for checking variable was set or exist on shell script
#!/bin/sh
a=1
b=2
# #Check whether they are equal
# if [ $a = $b ]
# then
# echo "a is equal to b"
# fi
@slaveofcode
slaveofcode / singleton.dart
Created March 24, 2021 18:17 — forked from theburningmonk/singleton.dart
Using Dart's factory constructor feature to implement the singleton pattern
class MyClass {
static final MyClass _singleton = new MyClass._internal();
factory MyClass() {
return _singleton;
}
MyClass._internal() {
... // initialization logic here
}
@slaveofcode
slaveofcode / browserless-unfurl.js
Created November 22, 2020 14:41 — forked from joelgriffith/browserless-unfurl.js
Unfurls a link into semantic data
import puppeteer from 'puppeteer';
function getTitle() {
if (document.querySelector('meta[property="og:title"]')) {
return document.querySelector('meta[property="og:title"]').content;
}
if (document.querySelector('[itemprop="name"]')) {
return document.querySelector('[itemprop="name"]').text;
}
if (document.querySelector('title')) {
@slaveofcode
slaveofcode / home-server.md
Created October 26, 2020 14:51 — forked from nileshtrivedi/home-server.md
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

@slaveofcode
slaveofcode / simple-gpg-enc.go
Created August 10, 2020 03:09 — forked from stuart-warren/simple-gpg-enc.go
golang gpg/openpgp encryption/decryption example
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@slaveofcode
slaveofcode / _readme.md
Created April 29, 2020 04:54 — forked from steeve/_readme.md
How to cross compile Go with CGO programs for a different OS/Arch

How to cross compile Go with CGO programs for a different OS/Arch

It is possible to compile Go programs for a different OS, even though go build says otherwise.

You'll need: