Skip to content

Instantly share code, notes, and snippets.


ngb ngbeslhang

View GitHub Profile
ngbeslhang /
Last active December 1, 2022 06:47
How to stop redirects when attempting to access UOW Malaysia KDU snapshots

TL;DR: replace http with https, such that e.g. becomes


Since I've just recently enrolled myself into a diploma programme for UOW Malaysia KDU (hereby referred to as KDU for the rest of the document), and since I'm living outside the campus, I need to rely on the university shuttle to go back and forth.

Out of curiosity, I decided to look at the historical snapshots of the transportation webpage on Wayback Machine, but all of the snapshots redirected me back to the original URL rendering me unable to access them at all, so I opened up the web developer tools > debugger to run the webpage step-by-step to see which script caused it.

I ended up finding out this:

ngbeslhang /
Last active July 8, 2022 23:12 — forked from andrewwatts/
urllib2 vs urllib3 vs requests; updated for Python 3
#!/usr/bin/env python3
import time
_URL = 'http://localhost/tmp/derp.html'
_NUMBER = 1000
def test_urllib2():
ngbeslhang /
Last active May 20, 2021 22:44
Python 3 script that converts Youtube playlists through youtube-dl into format-agnostic VLC-compatible .m3u8 playlist file in the order of the source playlist
# Requires youtube-dl option `--write-info-json` to work
# For this to work, you need to put this script into the directory (folder) of the videos and JSON files
import os
import json
# Separate JSON metadata files and media files
for path, dirname, filenames in os.walk(os.getcwd()):
json_filenames = [name for name in filenames if name.endswith('.info.json')]
media_filenames = [name for name in filenames if not name.endswith('.info.json')]

Keybase proof

I hereby claim:

  • I am ngbeslhang on github.
  • I am ngbeslhang ( on keybase.
  • I have a public key ASCmWDSopYy_a-jGhsdkc2kJuKoJpEz5xFGI8NCA93i2DQo

To claim this, I am signing this object:

View gist:1779e1ee2f076c8fbda1a73b66ba1b09
### Keybase proof
I hereby claim:
* I am ngbeslhang on github.
* I am ngbeslhang ( on keybase.
* I have a public key ASBevUCC8AlHQ3u-T8B_vVJTlb-Q3UYVtRoLnuFo5cV4TQo
To claim this, I am signing this object:
ngbeslhang /
Created August 13, 2018 06:43
Malaysian Phone Number Regex
ngbeslhang /
Created July 29, 2017 14:30 — forked from floer32/
DotDict is a variation of the classic "Bunch" recipe - just a dictionary, with all the normal dictionary methods, but the attributes are accessible by dot notation. Use this when you just really want to turn some dictionaries (i.e. from JSON) into something like JavaScript objects. Achieved with very little code. See bottom of docstring for Stac…
class DotDict(dict):
""" A dictionary whose attributes are accessible by dot notation.
This is a variation on the classic `Bunch` recipe (which is more limited
and doesn't give you all of dict's methods). It is just like a dictionary,
but its attributes are accessible by dot notation in addition to regular
`dict['attribute']` notation. It also has all of dict's methods.
.. doctest::
View regex-weburl.js
// Regular Expression for URL validation
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
// Copyright (c) 2010-2013 Diego Perini (
// Permission is hereby granted, free of charge, to any person
ngbeslhang /
Created April 15, 2017 15:41
Automatically download songs from links in a txt file because mom pls
import youtube_dl
ydl = youtube_dl.YoutubeDL({
'format': 'bestvideo+bestaudio',
"nocheckcertificate": True,
"keepvideo": True
with open("songs.txt", 'r') as q:
ngbeslhang / quak.txt
Last active March 28, 2017 22:09
Ctrl + F to search for Pokemon's name and corresponding key | Don't ask me why it's off center
View quak.txt
TIP: If you want to find the exact Pokedex number, surround one space between the number in Ctrl+F, e.g. " 1 " gives you exactly 1 result.
| | | |
| Key | Name | Region |
| | | |
| | | |
| 1 | Bulbasaur | Kanto |
| | | |