Skip to content

Instantly share code, notes, and snippets.

@techierishi
techierishi / main.go
Last active August 7, 2022 04:37 — forked from julz/main.go
Building a container from scratch in Go - Liz Rice (Microscaling Systems) https://www.youtube.com/watch?v=Utf-A4rODH8
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@techierishi
techierishi / MyClass.java
Created August 6, 2022 16:01
Promise.all using just thread
import java.time.Instant;
class ThreadT extends Thread {
int waitTime = 0;
ThreadT(int _waitTime){
this.waitTime = _waitTime;
}
public void run(){
@techierishi
techierishi / record.go
Created August 2, 2022 16:56 — forked from suapapa/record.go
raw audio recording with portaudio and golang
package main
import (
"encoding/binary"
"fmt"
"os"
"os/signal"
"time"
"github.com/gordonklaus/portaudio"
@techierishi
techierishi / leetcode-discuss-iframe.js
Last active July 18, 2022 19:07
Bring discussion tab in leetcode left to code editor
(function () {
'use strict';
const delay = ms => new Promise(res => setTimeout(res, ms));
function waitForElm(doc, selector) {
return new Promise(resolve => {
if (doc.querySelector(selector)) {
return resolve(doc.querySelector(selector));
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>modal</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/css/bootstrap.min.css" />
</head>
<body></body>
@techierishi
techierishi / envoyluadebug.lua
Created May 6, 2022 11:50
Lua envoyfilter debug
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
@techierishi
techierishi / 431.js
Created April 21, 2022 16:25
Create Random cookie to force browser to throw 431
function setCookie(name, value, days) {
let expires = '';
if (days) {
let date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = '; expires=' + date.toUTCString();
}
document.cookie = name + '=' + (value || '') + expires + '; path=/';
}
@techierishi
techierishi / alias_example.sh
Created February 21, 2022 14:37
Alias Snippet
alias whichcluster='kubectl config current-context'
# [Functions]
clusteradmin() {
ibmcloud ks cluster config --cluster "$1" --admin
}
# [/Functions]
version: "3.2"
services:
nginx:
image: nginx:latest
volumes:
- "nfs-data:/etc/nginx/nginx.conf"
volumes:
nfs-data:
@techierishi
techierishi / leftRight.js
Created October 25, 2021 19:51
Left right practive
function callNext(i)
{
const random = Math.random();
const random_boolean = random < 0.5
const msg = new SpeechSynthesisUtterance(random_boolean ? 'Left' : 'Right');
window.speechSynthesis.speak(msg);
if(i == 10)
return;