Skip to content

Instantly share code, notes, and snippets.

View jishanshaikh4's full-sized avatar
🌿

Jishan Shaikh jishanshaikh4

🌿
View GitHub Profile
@jishanshaikh4
jishanshaikh4 / split.sh
Created May 26, 2022 13:53
Split a 12 MB text file into 12 separate text files with index (Bash)
readarray -t lines < file.txt
count=${#lines[@]}
for i in "${!lines[@]}"; do
index=$(( (i * 12 - 1) / count + 1 ))
echo "${lines[i]}" >> "file${index}.txt"
done
@jishanshaikh4
jishanshaikh4 / thee-ree.js
Created May 25, 2022 16:55
three.js sample animation
import * as THREE from 'three';
// init
const camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 1;
const scene = new THREE.Scene();
const geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
(function () {
/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
"use strict";
var l;
function aa(a) {
var b = 0;
@jishanshaikh4
jishanshaikh4 / pwnd.php
Created May 20, 2022 09:48
Check whether your password has been leaked
<?php
/**
* Simple method to use the API from https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/
* Released to public domain
* @return int count
*/
function checkPawnedPasswords(string $password) : int
{
$sha1 = strtoupper(sha1($password));
$data = file_get_contents('https://api.pwnedpasswords.com/range/'.substr($sha1, 0, 5));
@jishanshaikh4
jishanshaikh4 / torhasher.py
Created May 17, 2022 07:20 — forked from james-see/torhasher.py
create a hashed password for control port setting in torrc HashedControlPassword line easily with this (python2)
import os, binascii, hashlib
#supply password
secret = 'your password here you want to use' # all you need to change!
#static 'count' value later referenced as "c"
indicator = chr(96)
#used to generate salt
rng = os.urandom
import math
from moviepy.editor import concatenate, ImageClip
import os
import platform
import subprocess
import random
import torch
# pip install pytorch-pretrained-biggan
from pytorch_pretrained_biggan import (BigGAN, truncated_noise_sample, convert_to_images)
import numpy as np
@jishanshaikh4
jishanshaikh4 / cmds.md
Created May 12, 2022 10:39
Common Commands - Utility

cloc

$ cloc count lines of code.

Use as: $ cloc ./ or $ cloc ./*.py

convert

$ convert convert .gif or .mp4 to many png frames

Use as: $ convert -coalesce my_animatedfile.gif my_pngfiles.png

@jishanshaikh4
jishanshaikh4 / total_sum.js
Created May 11, 2022 06:33
Sum of JSON/JS Array (key:value) numerical values
function addFieldsForItem (arrName = []) {
arrName.forEach(function(item) {
let total = 0;
Object.keys(item).forEach(function(key) {
if (typeof item[key] === 'number') {
total = total + item[key]
}
})
item.total = total
})

“Fools ignore complexity; pragmatists suffer it; experts avoid it; geniuses remove it.”

– Alan Perlis (Turing Award #1, ALGOL)


“Computer Science is the first engineering discipline in which the complexity of the objects created is limited solely by the skill of the creator, and not by the strength of raw materials.”

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?