Skip to content

Instantly share code, notes, and snippets.

View iThanh's full-sized avatar
🎯
Focusing

iThanh iThanh

🎯
Focusing
View GitHub Profile
@iThanh
iThanh / 403forbidden.php
Created August 12, 2018 06:36 — forked from frankleromain/403forbidden.php
Creating a Secure PHP Login Script
<?php
header('HTTP/1.1 403 Forbidden');
?>
<html>
<head>
<title>Congratulations! You have been DENIED access</title>
</head>
<body>
<font size="4">You have been denied access because of the following reasons:<br /><br />
1.) Too many failed login attempts, so you are likely brute forcing through logins.<br />
@iThanh
iThanh / mobile-networks-types.md
Created July 5, 2018 03:03 — forked from igrigorik/mobile-networks-types.md
Bandwidth ceiling mappings for different generation networks. See: https://github.com/w3c/netinfo/issues/13#issuecomment-53095864
Android iOS Gen Down max
NETWORK_TYPE_CDMA 2G
NETWORK_TYPE_IDEN 2G
NETWORK_TYPE_GPRS CTRadioAccessTechnologyGPRS 2.5G
NETWORK_TYPE_EDGE CTRadioAccessTechnologyEdge 2.75G
NETWORK_TYPE_1xRTT CTRadioAccessTechnologyCDMA1x 3G
NETWORK_TYPE_UMTS CTRadioAccessTechnologyWCDMA 3G
NETWORK_TYPE_EVDO_0 CTRadioAccessTechnologyCDMAEVDORev0 3.5G
NETWORK_TYPE_EVDO_A CTRadioAccessTechnologyCDMAEVDORevA 3.5G
@iThanh
iThanh / detect-private-browsing.js
Created June 3, 2018 22:27 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@iThanh
iThanh / proxy-toggle.sh
Created March 20, 2018 16:38 — forked from mnewt/proxy-toggle.sh
trivial command to toggle Mac OS X SOCKS proxy
#!/bin/sh
PROXY_INTERFACE="USB Ethernet"
PROXY_HOST=localhost
PROXY_PORT=1080
if [[ $1 == "on" ]]; then
sudo networksetup -setsocksfirewallproxy "$PROXY_INTERFACE" $PROXY_HOST $PROXY_PORT
echo "SOCKS proxy enabled"
@iThanh
iThanh / proxy-toggle.sh
Created March 20, 2018 16:38 — forked from dgoguerra/proxy-toggle.sh
Script to toggle Mac OS X SOCKS proxy, and setup a SOCKS server with SSH
#!/bin/sh
PROXY_INTERFACE="Wi-Fi"
PROXY_HOST=127.0.0.1
PROXY_PORT=1080
# A host where ssh can login without interaction, with a key-based
# authentication.
SOCKS_PROC_USER="username"
SOCKS_PROC_HOST="example.com"
@iThanh
iThanh / ImageZoom.swift
Created December 28, 2015 11:38 — forked from acrookston/ImageZoom.swift
Swift image zoom
// The image is originally animated on to the view controller then added to the scroll view.
// So, there might be some animation residue in here.
// Class needs: <UIScrollViewDelegate>
func viewDidLoad() {
let width = UIScreen.mainScreen().bounds.size.width
let aspect: CGFloat = width / shotWidth
var frame = CGRectMake(0, 0, shotWidth * aspect, shotHeight * aspect)
self.scrollView = UIScrollView(frame: frame)