Skip to content

Instantly share code, notes, and snippets.

View umstek's full-sized avatar
🏠
Working from home

Wickramaranga Abeygunawardhana umstek

🏠
Working from home
View GitHub Profile
@umstek
umstek / html5-video-streamer.js
Created June 9, 2016 09:13 — forked from RajaRamesh/html5-video-streamer.js
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@umstek
umstek / main.js
Last active July 23, 2016 06:31
Simple NodeJS server, serving static files.
var fs = require('fs');
var http = require('http');
http.createServer(function (request, response) {
var path = request.url;
console.log(request.method, request.url);
if (path === '/') { // Serving default page from code instead of a file.
var html = "<!DOCTYPE html>" +
"<html>\n" +
@umstek
umstek / switch.py
Created July 31, 2016 17:22
A switch control structure, as an expression, implemented in python3 without using any control structures.
print(
(
lambda value, cases, default:
{
True: lambda: cases[value],
False: lambda: default
}[value in cases]()
)(
int(input()), {1: 'case 1', 2: 'case 2', 3: 'case 3'}, 'default'
)
@umstek
umstek / VirusShareMD5toBIN.py
Last active May 13, 2017 15:57
Convert MD5 hashes from VirusShare back to binary
import os
if not os.path.exists('bin'):
os.makedirs('bin')
for i in range(0, 289):
print(f'Parsing file {i:d}')
lines = open('VirusShare_' + f'{i:05d}' + '.md5').readlines()[6:]
@umstek
umstek / git-isolated-branch.txt
Created July 15, 2017 08:48
Create a clean new branch in git without shared history
git checkout --orphan <newbranch>
git rm -rf .
<...do work...>
git add your files
git commit -m 'Initial commit'
@umstek
umstek / cache-clean.md
Last active November 25, 2017 08:04
Developer Hacks

Linux/Ubuntu

Clean the APT Cache

Show size: du -sh /var/cache/apt/archives
Clean: sudo apt-get clean

Remove packages those are no longer needed

sudo apt-get autoremove --purge

YUM

yum clean all

@umstek
umstek / reversetunnel.sh
Last active March 30, 2020 16:36
Snippets for work
# Enter this on local terminal to forward connections to 4007 on remote computer to 4005 on local computer
ssh -R 4007:localhost:4005 username@192.168.43.21
@umstek
umstek / commands.md
Last active January 16, 2024 13:07
Useful commands

Delete all node_modules folders

find . -name "node_modules" -prune -exec rm -rf '{}' +

Flatten directory structure

find /dir1 -mindepth 2 -type f -exec mv -t /dir1 -i '{}' +
@umstek
umstek / downloader.ipynb
Created April 15, 2024 10:01
downloader
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@umstek
umstek / dedupe.ts
Created June 8, 2024 14:15
Deduplicate ESLint configs migrated with Biome
// Needs Bun
import biome from './biome.json';
// Extracted from https://biomejs.dev/linter/rules/#recommended-rules
const recommended = (await Bun.file('./recommended.txt').text())
.split('\n')
.map((x: string) => x.trim())
.filter(Boolean);