Skip to content

Instantly share code, notes, and snippets.

View angeloped's full-sized avatar

Angeloped angeloped

  • Philippines
View GitHub Profile
@angeloped
angeloped / tz_date.php
Last active March 24, 2019 14:13
Unix timestamp by timezone in PHP.
<?php
# note: $_REQUEST["tz"] is variable of your timezone. arg example: Asia/Manila
if(isset($_REQUEST["tz"])){
date_default_timezone_set($_REQUEST["tz"]);
$datetime = new DateTime();
echo $datetime->format('Y-m-d H:i:s');
die();
}
?>
@angeloped
angeloped / get_available_net_interface.py
Created March 24, 2019 13:57
Get available network interface.
import psutil
addrs = psutil.net_if_addrs()
print(addrs.keys())
@angeloped
angeloped / get_network_mac.py
Last active September 24, 2019 08:24
Get the mac address of all available network interface. Netifaces alternative.
import socket, psutil
from binascii import hexlify
# get mac address
def get_network_mac(interface, p=0):
# create dummy socket
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
# bind it with interface name
s.bind((interface,p))
@angeloped
angeloped / change_vol.py
Created March 31, 2019 16:35
Change master audio volume in Linux using python.
import subprocess
def get_master_volume():
proc = subprocess.Popen('/usr/bin/amixer sget Master', shell=True, stdout=subprocess.PIPE)
amixer_stdout = proc.communicate()[0].split('\n')[4]
proc.wait()
find_start = amixer_stdout.find('[') + 1
find_end = amixer_stdout.find('%]', find_start)
return float(amixer_stdout[find_start:find_end])
@angeloped
angeloped / serial_monitor.py
Last active May 29, 2019 08:50
A simple low-level I/O serial monitor using Python os.open() on Linux.
import os
try:
device = os.open("/dev/ttyUSB0", os.O_RDWR)
while 1:
print(os.read(device,255))
finally:
os.close(device)
@angeloped
angeloped / bypass_subscription.js
Last active June 24, 2019 12:42
This is the script for MIT Tech Review articles subscription bypass. Happy hacking!
document.getElementsByClassName("jsx-963942478 paywallWrapper")[0].remove();
document.querySelector("body").setAttribute("style", "overflow: scroll;");
@angeloped
angeloped / currency_formatter.py
Last active June 24, 2019 12:41
A currency formatter written in Python.
# all num is converted into float
def currency_format(num):
sol = str(float(num)).split(".")
sol[0] = sol[0][::-1]
final = ""
while len(sol[0]):
sol_r_e = sol[0][:3]#slice (get 3 characters)
sol[0] = sol[0][3:]#slice (decrease)
if len(sol_r_e) == 3 and not len(sol[0]) == 0:sol_r_e += ","
final += sol_r_e
@angeloped
angeloped / cutcopypaste.py
Created June 24, 2019 12:40
A simple Tkinter Cut, Copy, and Paste contextmenu for Entry widgets.
import Tkinter
def make_textmenu(root):
global the_menu
the_menu = Tkinter.Menu(root, tearoff=0)
the_menu.add_command(label="Cut")
the_menu.add_command(label="Copy")
the_menu.add_command(label="Paste")
the_menu.add_separator()
the_menu.add_command(label="Select all")
@angeloped
angeloped / MyHTMLParser.py
Created July 4, 2019 03:21
A simple HTML parser with HTMLParser module for Python 2.X.
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print("Start tag:", tag)
for attr in attrs:
print(" attr:", attr)
def handle_endtag(self, tag):
print("End tag :", tag)
@angeloped
angeloped / download_HTML5Player_content.js
Last active August 16, 2019 10:48
HTML5Player Video Downloader using JavaScript. Proof of concept: xDxNxXxD
/*HTML5Player Video Downloader using JavaScript. Proof of concept: x_*n_*x*_x_ LOL! */
window.location=html5player.url_high;
/*
//or option 2:
obj=document.getElementsByClassName("transition")[2];
obj.setAttribute("href",html5player.url_high);
obj.innerHTML="<h1>" + html5player.video_title + "</h1>";
*/