Skip to content

Instantly share code, notes, and snippets.

View aalfiann's full-sized avatar
🏠
Working from home

M ABD AZIZ ALFIAN aalfiann

🏠
Working from home
View GitHub Profile
@aalfiann
aalfiann / minify_page.php
Created November 8, 2017 08:08
Function to minify your page on the fly using php
/** To use minify with ob_start just put at the top of your page
* Warning:
* - This function still not support to remove any comments in javascript
* - Minifying on buffering will take so much memory and it not recomended for high traffic
*/
function sanitize_output($buffer) {
$search = array(
// Minify HTML
'/\>[^\S ]+/s', // strip whitespaces after tags, except space [^1]
@aalfiann
aalfiann / proxy_curl.php
Created November 25, 2017 04:47 — forked from mlconnor/proxy_curl.php
PHP CURL Code to grab a file through a proxy
<?php
print get_file('http://www.google.com');
function get_file($url) {
$curl = curl_init();
$options = default_ops(array(CURLOPT_URL => $url));
curl_setopt_array($curl, $options);
$output = curl_exec($curl);
<?php
echo preg_replace('#<a.*?>([^>]*)</a>#i', '$1', $str);
?>
@aalfiann
aalfiann / sharing_memory.html
Created January 17, 2018 04:34
Sharing memoryStorage between tabs for secure multi-tab authentication
<!DOCTYPE html>
<html>
<head>
<title>Sharing memoryStorage between tabs for secure multi-tab authentication</title>
</head>
<body>
<h3><a href=''>memoryStorage</a></h3>
<h3 id="stData"></h3>
<button id="btnSet">Set memory storage</button>
@aalfiann
aalfiann / gist:c0cbb90b8cbdd7845da0359245bdbdb1
Created February 1, 2018 12:13 — forked from yonjah/gist:5082855
Blocking DDOS bots with JavaScript for fun and profit! Or how easy it is to break the current protection methods and how to make it better.
TL;DR - jump to the challenge at the end
====ON BLOCKING EVIL BOTS=====
On a resent job interview I had for "Incapsula" a few days ago I was put to the challenge to break
their bot protection mechanism. Apparently node.js is not that common among bot writes and most bots
are not able to run javascript.
The challenge had two parts -
1. find what the code does.
2. implement a bot that will break the code without using js.
3. think how to make this code unbreakable
@aalfiann
aalfiann / simple_encrypt.js
Created February 10, 2018 16:18
JS Simple encryption
var key = "SXGWLZPDOKFIVUHJYTQBNMACERxswgzldpkoifuvjhtybqmncare";
// matches ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
function encodeStr(uncoded) {
uncoded = uncoded.toUpperCase().replace(/^\s+|\s+$/g,"");
var coded = "";
var chr;
for (var i = uncoded.length - 1; i >= 0; i--) {
chr = uncoded.charCodeAt(i);
coded += (chr >= 65 && chr <= 90) ?
@aalfiann
aalfiann / .gitignore
Created February 13, 2018 08:42 — forked from SaltwaterC/.gitignore
php cache curl
/cache/
@aalfiann
aalfiann / global-debugger.js
Created February 27, 2018 05:23
Global debugger javascript class
/**
* Global debugger class
* @param states = debugger will run if states is set to true
* @param klass = classical interface to prototypal inheritance
*/
var Debugger = function(states, klass) {
this.debug = {}
if (states && klass.isDebug) {
/* Request Fullscreen on spesific element */
function requestFullScreen(element) {
// Supports most browsers and their versions.
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
if (requestMethod) { // Native full screen.
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
@aalfiann
aalfiann / multiple-acao-htaccess.txt
Created March 14, 2018 11:52
Example multiple ACAO in htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>
<IfModule mod_headers.c>
# Example multiple Access Control Allow Origin (ACAO)