Skip to content

Instantly share code, notes, and snippets.

@chukonu
chukonu / ssh_wsl.md
Created January 10, 2024 10:29
Add an SSH key in WSL
eval "$(ssh-agent)"
ssh-add <key>
@chukonu
chukonu / FluxHandleExample.java
Created May 7, 2022 10:27
Flux.handle example
import reactor.core.publisher.Flux;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class FluxHandleExample {
public static void main(String[] args) throws InterruptedException, ExecutionException {
CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
@chukonu
chukonu / p12.js
Created April 17, 2019 07:39
HTTP request w/ p12
'use strict';
const fs = require('fs');
const path = require('path');
const request = require('request');
const opts = {
url: '',
qs: {
},
@chukonu
chukonu / styling-scrollbar.css
Created September 7, 2018 09:56
Google Docs-style scrollbar
// Override webkit browsers' default scrollbar styles
::-webkit-scrollbar {
width: 12px;
height: 12px;
}
::-webkit-scrollbar-button {
height: 0;
width: 0;
@chukonu
chukonu / array_to_tree.go
Created June 22, 2018 06:46
Convert sorted arrays to balanced BSTs
// xkool 22.06.18
package main
import "fmt"
type Node struct {
Data int
Left, Right *Node
}
@chukonu
chukonu / array-like.js
Created May 25, 2018 07:32
Turning an array-like object into an array
// Turn an array-like object into an array
let nodeList = document.querySelectorAll('div') // an array-like object
Array.prototype.slice.call(nodeList)
@chukonu
chukonu / extract.js
Created March 26, 2018 04:29
Extracts x and y from a CSS polygon clip-path string
// extracts x and y from a CSS polygon clip-path string
function extractPoints(str) {
// 'polygon(' - starts from index 8
// ends at length-1
let s = str.substring(8, str.length - 1)
let pointStrs = s.split(',').map(p => p.trim())
return pointStrs.map(str => {
let percentages = str.split(' ')
return {
x: excludePercentSign(percentages[0]),
@chukonu
chukonu / server.js
Last active September 12, 2017 02:43
a premature test server for basic authentication
const express = require('express')
const app = express()
const port = 3000
const host = '192.168.10.112'
const realm = 'protected'
const templ = fillTempl`<html>
<head><title>${0}</title></head>
<body><h1>${1}</h1></body>
</html>`
@chukonu
chukonu / cache-nuget.go
Last active September 29, 2016 02:28
Exec external commands
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"os/exec"
"time"