Skip to content

Instantly share code, notes, and snippets.

View ngbeslhang's full-sized avatar

ngb ngbeslhang

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

TL;DR: replace http with https, such that e.g. http://web.archive.org/web/20210617234942/https://www.uowmkdu.edu.my/study-at-uow-kdu/transportation/ becomes https://web.archive.org/web/20210617234942/https://www.uowmkdu.edu.my/study-at-uow-kdu/transportation/.

Journey

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
ngbeslhang / request_time.py
Last active July 8, 2022 23:12 — forked from andrewwatts/request_time.py
urllib2 vs urllib3 vs requests; updated for Python 3
#!/usr/bin/env python3
import time
# REMEMBER TO CHANGE THE VARIABLES BELOW BEFORE YOU RUN THE SCRIPT
_URL = 'http://localhost/tmp/derp.html'
_NUMBER = 1000
def test_urllib2():
@ngbeslhang
ngbeslhang / playlist_creator.py
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
# MADE AND TESTED ONLY FOR YOUTUBE PLAYLISTS
# 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 (https://keybase.io/ngbeslhang) on keybase.
  • I have a public key ASCmWDSopYy_a-jGhsdkc2kJuKoJpEz5xFGI8NCA93i2DQo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am ngbeslhang on github.
* I am ngbeslhang (https://keybase.io/ngbeslhang) on keybase.
* I have a public key ASBevUCC8AlHQ3u-T8B_vVJTlb-Q3UYVtRoLnuFo5cV4TQo
To claim this, I am signing this object:
@ngbeslhang
ngbeslhang / README.md
Created August 13, 2018 06:43
Malaysian Phone Number Regex
@ngbeslhang
ngbeslhang / dot_dict.py
Created July 29, 2017 14:30 — forked from floer32/dot_dict.py
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::
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@ngbeslhang
ngbeslhang / download.py
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:
ydl.download(q.readlines())
@ngbeslhang
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
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 |
| | | |