Skip to content

Instantly share code, notes, and snippets.

View roshnet's full-sized avatar
🏎️
working from cache

Roshan Sharma roshnet

🏎️
working from cache
View GitHub Profile

From https://ss64.com/pass/command-line.html -

# Bash version
strongpw() {
    read -rs -p 'Encryption key: ' key
    echo '' # line break
    echo -n "$key:$1" | sha256sum | perl -ne "s/([0-9a-f]{2})/print chr hex \$1/gie" | base64 | tr +/ Ea | cut -b 1-20
}
@roshnet
roshnet / gitlab-runner-local.md
Created September 16, 2022 09:50
Local GitLab CI installation

Run GitLab CI jobs locally

  1. Get runner image - docker pull gitlab/gitlab-runner:latest
  2. Clone & change into source code dierctory (ensure .gitlab-ci.yml exists and is valid) - cd <REPO>
  3. Start a container called gitlab-runner0 -
docker run -d \--name gitlab-runner0 \
   --restart always \
 -v $PWD:$PWD \
@roshnet
roshnet / veritasium.js
Last active September 4, 2022 11:04
A Node.js script for Veritasium's riddle (youtu.be/iSNsgj1OCLA)
const N = 100
const TO_FIND = 42
const BOXES = {}
let iterations = 0
const trail = []
/**
* @description Return a fresh set of slips on each call.
*/
@roshnet
roshnet / main.js
Created April 23, 2022 11:10
uCrypt encryption module reference
const crypto = require('crypto')
const fs = require('fs')
const ALGO = 'aes-256-ctr'
// const message = Buffer.from('Enemies incoming!', 'binary')
const message = fs.readFileSync('docs.pdf', { encoding: 'binary' })
const password = 'secret'
const key = crypto
.createHash('sha256')
@roshnet
roshnet / wallet.js
Last active November 24, 2021 10:55
Implementing the given methods in the Wallet class
/*
Mnemoics used -
quality armor buddy double food laugh tunnel marine lizard west cup what basket lumber walnut link frog rice pigeon abstract nurse volcano curve twice
Generated tpub from iancoleman.io/bip32
tpubDC93eCC1ySXoBp7AKVv9M9uRi4evZjwgd8LbmYuhXs6NnarvhHsNFPcrzwPqsrUa3y5E5FjnbGE4Li55Y5G96aaPJsb2DKagQC8zgpcRcMQ
Generated Account extended private key from iancoleman.io/bip32
tprv8fT1Vn9mq4r8JM5NRrFYwkFK938zQQkn3pjpV2sQ7bHyx6cA4u3n4tzzpn9vJysFzvbLW2VSUDgG9bPQhxGKhfxvyc8wVMahKNFVPL8aMqv
@roshnet
roshnet / randomgame.js
Created October 30, 2021 20:51
I was bored...
import { useLayoutEffect, useState } from 'react'
const SECONDS = 0.6
export default function Game() {
const [x, setX] = useState(0)
const [y, setY] = useState(0)
const [score, setScore] = useState(0)
// Change coordinates every N seconds
@roshnet
roshnet / tabcloser.cs
Last active September 13, 2021 13:27
Close Chrome tabs in C# (Windows)
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Automation;
using System.Windows.Forms;
namespace NudgeApp {
class ChromeTabBlocker {
[DllImport("user32.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
@roshnet
roshnet / jinja2_file_less.py
Created October 3, 2020 11:03 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
var crypto = require("crypto");
var algorithm = "aes-192-cbc";
var password = "Store this password in a .env file!";
const key = crypto.scryptSync(password, 'salt', 24);
var text = "secret message";
const iv = crypto.randomBytes(16); // different each time
const cipher = crypto.createCipheriv(algorithm, key, iv);
function placeOrder(user) {
var order;
order.buyer = user;
order.itemName = 'Raspberry Pi';
order.itemPrice = 2500;
order.isConfirm = true;
return order;
}
var person = {
name: 'John',