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
@zikani03
zikani03 / go.mod
Created September 28, 2023 10:42
Transaction ID generator experiment
module go.zikani.me/labs/transactionizer
go 1.21.1
require (
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.3.0
github.com/speps/go-hashids/v2 v2.0.1
github.com/zikani03/pgadvisorylock v0.2.0
)
@zikani03
zikani03 / primevue.code-snippets
Created September 20, 2022 10:10
Primevue Utilities
{
// VS Code Snippers for PrimeVue components
// @author Zikani Nyirenda Mwase <[email protected]>
"p-inputtext": {
"scope": "vue,javascript,typescript,html",
"prefix": "pi:text",
"body": [
"<div class=\"field\">",
" <div class=\"p-float-label\">",
" <InputText id=\"$1\" v-model=\"$1\"/>",
@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
@zikani03
zikani03 / README.md
Created September 14, 2020 19:31
SparkJava powered by Project Loom

This is a simple experiment using a build of Java 16 to create a simple Spark Java application that's backed by Project Loom's Virtual Threads as Jetty's ThreadPool implementation. It is based on prior art

What does it do?

It's basically a web server whose routes/endpoints are specified with Spark to serve an HTML page and some JavaScript - written inline using Text Blocks!.

@zikani03
zikani03 / MultiplexOutputStream.java
Last active September 19, 2024 14:04
Writing to multiple output streams in Java
import java.io.IOException;
import java.io.OutputStream;
/**
* <p>
* MultiplexOutputStream allows you to write to multiple output streams "at once".
* It allows you to use one outputstream writer to write to multiple outputstreams
* without repeating yourself.
* Based off <a href="https://github.com/creditdatamw/kapenta/blob/master/src/main/java/com/creditdatamw/labs/kapenta/io/MultiplexOutputStream.java">MultiplexOutputStream.java</a>
*/
@zikani03
zikani03 / pentaho_query_reader.rs
Created July 18, 2017 11:12
Extract SQL queries from pentaho files with Rust
extern crate zip;
extern crate quick_xml;
extern crate html_entities;
use std::io::BufReader;
use std::fs::File;
use std::io::Read;
use std::ops::Deref;
use std::collections::BTreeMap;
use zip::read::ZipArchive;
@zikani03
zikani03 / index.js
Created April 22, 2017 11:37
Rust + Node via Postgres notify/listen
var pg = require('pg');
var client = new pg.Client('postgresql://username:password@localhost:5432/labs');
client.connect();
client.query('LISTEN events', function(err, msg) {
if (err) throw err;
});
@zikani03
zikani03 / gist:7c82b34fbbc9a6187e9a
Created June 4, 2015 10:29
Simple Cors Filter for Spark Java
import java.util.HashMap;
import spark.Filter;
import spark.Request;
import spark.Response;
import spark.Spark;
/**
* Really simple helper for enabling CORS in a spark application;
*/
public final class CorsFilter {
var cmd = require("cmd.js"),
truncate = require("./truncate");
cmd.module('truncate', truncate);
var articles = [
{ title: "Lorem ipsum dolor sit amet, musis nihilominus admonendus tu tu", body : "Lorem ipsum dolor sit amet, caelum levaverunt te finis puellam. Aderit omnia salva deus Hellenici silentio flebam terris classes nostram."},
{ title: "My first article", body: "Ego esse ait mea Christianis, concursus male nuptiarum civibus nescis. Quos ducem cum magna duobus discessit de me in deinde cupis ei."},
{ title: "My second article post", body : "Mansione sed eu fugiens laudo in, zurziaca in fuerat construeret cena. Nubila grata gratias eos est Apollonius in modo invenit nutricis actum in lucem."},
{ title: "This is just an article", body : "Filiam sunt amore tolle quae non potentiae cognoscitivarum non ait. Neminem habere matrem Domini in fuerat eum filiam rex Dionysiadi rex Dionysiadi rex in modo ad per sanctus primum subsannio."}
@zikani03
zikani03 / row_to_csv.sql
Last active December 18, 2015 04:49
I was looking for a way to create a csv record of a row so i could use in a query.
-- @name row_to_csv
-- @descr create a csv record of any row from any table in MSSQL 2005+
-- @param table_name : full schema qualified name e.g. [dbo].[companies]
-- @param conditions select conditions .e.g "WHERE companies.company_id = 50
CREATE FUNCTION dbo.row_to_csv( @table_name as varchar(100) , @conditions as varchar(200))
returns varchar(2048)
AS
begin
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''+@table_name) AND type in (N'U'))