Skip to content

Instantly share code, notes, and snippets.

View zikani03's full-sized avatar
🏍️
Progress is intentional

Zikani Nyirenda Mwase zikani03

🏍️
Progress is intentional
View GitHub Profile
@Skarlso
Skarlso / main.go
Created February 16, 2019 21:31
Golang SSH connection with hostkey verification
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@alexedwards
alexedwards / gist.go
Created April 27, 2019 17:00
SCS v2 Custom Middleware
package main
import (
"bytes"
"io"
"log"
"net/http"
"github.com/alexedwards/scs/v2"
)
@SharkFourSix
SharkFourSix / AntiXsrfCookie.java
Last active July 2, 2019 15:14
Anti-XSRF Cookies in Spark Java using 'SameSite' flag
import javax.servlet.http.Cookie;
import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public final class AntiXsrfCookie extends Cookie {
private static final String SAME_SITE_LAX = "Lax";
private static final String SAME_SITE_STRICT = "Strict";
@SharkFourSix
SharkFourSix / HttpsRedirector.java
Last active July 2, 2019 15:15
Spark Java HTTP to HTTPS redirector
import java.io.Closeable;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set;
public final class HttpsRedirector {
@MakawaMT
MakawaMT / sms_regex_malawi.java
Created October 17, 2019 13:33
Contains regular expressions for SMSes returned when payment is done using the mobile money/bank providers. Regex can be tested at Regex planet https://www.regexplanet.com/ . The REGEX contains named groups which can help you extract particular information for that transaction which can be used for accountability and confirmation
/*
* Copyright (c) 2019 Lomaku Technologies.
* All Rights Reserved.
* 40 Estate Road, Angelo Goveya, Limbe.
* +265 999 388 747
* https://github.com/LomakuIT
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
#!/bin/bash
# Recommended steps:
#
# bootstrap before entering chroot
# copy this script into INSTALL_DIR
# rootinit after entering chroot
# x (if installing graphics)
# pkgs
# xpkgs (if installing graphics)
@ereli
ereli / hello.go
Last active February 20, 2025 21:54
How to sign macOS and Windows executables using self-signed certificates on a Mac.
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
@scastiel
scastiel / Makefile
Last active December 12, 2024 16:00
Resources for eBook creating using Pandoc
all: pdf epub kindle html examples
BOOK_TITLE = A\ React\ Developer’s\ Guide\ to\ Hooks\ -\ Sebastien\ Castiel
dist:
@mkdir -p dist
pdf: dist/${BOOK_TITLE}.pdf
@echo '✅ PDF'
@Tostino
Tostino / uuid_time_nextval.sql
Created January 22, 2021 20:09
PL/PGSQL Function for uuid_time_nextval
CREATE FUNCTION uuid_time_nextval(interval_length int default 60, interval_count int default 65536)
RETURNS uuid
LANGUAGE plpgsql
AS $$
DECLARE
v_i int;
v_prefix_bytes int = 0;
v_time bigint;
v_bytes int[16] = '{}';
v_hex text[16] = '{}';
@zikani03
zikani03 / chremote.py
Last active September 15, 2021 19:45
chremote.py: Change https -> ssh remote urls for GitHub repos in a directory
#!/usr/bin/python
"""Changes remote urls for repositories in a given directory to SSH remotes
for repositories in a given directory. Since GitHub removed password based auth.
Run it using: `python chremote.py --d /path/to/directory`
Basic interaction is outlined below;
```
$ ls /path/to/directory