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 / gif_exporter.cpp
Last active February 17, 2021 09:29
My GIFExporter class for use with ffmpeg (version 4 only?) and Qt5. Also supports cropping all the image frames before encoding. Licensed under dual BSD/MIT license.
#include <QtWidgets>
#include <iostream>
#include <cstdlib>
// extern "C" prevents linker errors when using this in a C++ program.
// Remove 'extern "C" {' if putting this in a C program.
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
@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();
}
}