Skip to content

Instantly share code, notes, and snippets.

View ZenulAbidin's full-sized avatar
🎯
Focusing...

Ali Sherief ZenulAbidin

🎯
Focusing...
View GitHub Profile
from io import BufferedReader, StringIO, UnsupportedOperation
# Because this is a read-only stream, write methods raise an exception.
class BufferedStringReader:
def __init__(self, string, name, mode):
if mode != 'rb' and mode != 'br':
raise ValueError("invalid mode: " + mode)
self.reader = open(name, mode)
self.stringio = StringIO(string)
self.string = string
import random
#++++++++ 1
No_man = ['________',
'| |',
'| ',
'| ',
'| ',
'| ',
'| ']
@ZenulAbidin
ZenulAbidin / day29.py
Created February 23, 2020 20:23
Day 29: Bitwise AND
#!/bin/python3
import math
import os
import random
import re
import sys
@ZenulAbidin
ZenulAbidin / test_cases.cpp
Created February 24, 2020 18:11
Code I wrote so far. I need a way to pass multiple arguments to a boost test function.
#define BOOST_TEST_MODULE paintColor
#include <boost/test/included/unit_test.hpp>
using namespace std;
void colorpaint_test_function( string s, string out, vector<float> expected )
{
cout << out << endl << "=========" << endl;
vector<float> v = paintColor(s); // paintColor() defined elsewhere
copy(v.begin(), v.end(), ostream_iterator<float>(cout, " "));
cout << endl;
@ZenulAbidin
ZenulAbidin / omega-ascii-sans-upper.txt
Created March 16, 2020 17:15
Omega Neon Sans - uppercase only. Characters are written in Unicode order, Licensed under CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/
╔██╗╔██╗╔██╗ ╔██╗╔██╗╔██╗ ╔███████╗ ╔███╗ ╔████╗
║██║║██║║██║╔████████████╗╔██╔██╔══╝╔██╗ ╔███╔╝ ╔██╔╗██
║██║╚══╝╚══╝╚╗██╗╔██╗╔██╔╝╚╗██████╗ ╚══╝╔███╔╝ ╚╗████╝╔█╗
╚══╝ ╔████████████╗ ╚═╗██╗██╗ ╔███╔╝╔██╗╔██╔╗███╔╝
╔██╗ ╚╗██╔╗██╔╗██╔╝╔███████╔╝ ╔███╔╝ ╚══╝╚╗███████╗
╚══╝ ╚══╝╚══╝╚══╝ ╚═══════╝ ╚═══╝ ╚═══════╝
╔███╗ ╔████╗╔████╗ ╔██╔██╗ ╔██╗ ╔███╗
║███║╔██╔══╝╚══╗██╗╔███████╗╔██████╗ ╔███╔╝
╚═══╝║██║ ║██║╚╗██╔██╔╝╚═╗██╔═╝ ╔█████╗ ╔███╔╝
║██║ ║██║ ╚══╝╚═╝ ╚══╝ ╔█╗╚═════╝ ╔███╔╝
@ZenulAbidin
ZenulAbidin / pushshift_authors.py
Last active March 27, 2020 19:52
Template script that can retrieve the authors of reddit posts made after a specific date.
# Retrieves authors of the first 10 posts of /r/politics
# excluding deleted users.
# You can then feed these into DownloaderForReddit
# install pushift.py using `pip3 install pushshift.py`
# from pushshift_py import PushshiftAPI
# I don't know if 'banned_by_rpolitics' is someone's username
# or a banned user.
from pushshift_py import PushshiftAPI
api = PushshiftAPI()
@ZenulAbidin
ZenulAbidin / jwfileconvert.py
Last active April 12, 2020 23:48
Converts JWplayer filenames to a episode order + title filename, removing funny numbers. Tested on videos ripped from itpro.tv using jdownloader.
import json
import os
import glob
import ntpath
mp4path_dir = "/directory/path" # No trailing slash please
actual_json = json.load(open('path to json file'))
os.chdir(mp4path_dir)
@ZenulAbidin
ZenulAbidin / find.sh
Created April 18, 2020 00:49
I don't want to forget this
find . -name 'index.html*' -exec grep -H 'STRING' {} \;
@ZenulAbidin
ZenulAbidin / anchorsHashRouter.js
Created April 29, 2020 22:49
Makes HTML anchors defined with ref work with HashRouters in react apps.
componentDidMount() {
// Other initialization...
// IMPORTANT: Put this after "document.body.classList.toggle"
let hash = this.props.location.hash.replace('#', '');
if (hash) {
let node = ReactDOM.findDOMNode(this.refs[hash]);
if (node) {
node.scrollIntoView();
}
}
@ZenulAbidin
ZenulAbidin / resize.js
Created May 11, 2020 18:44
Resizes my pictures in a directory to 64x64 pixels using sharp.js and exports them to another directory.
const src = 'a';
const dst = 'asmol';
const fs = require('fs');
var path = require('path')
const homedir = require('os').homedir();
const sharp = require('sharp');
var srcFolder = path.join(homedir, 'images', src)
var dstFolder = path.join(homedir, 'images', dst)
fs.readdir(srcFolder, (err, files) => {