Skip to content

Instantly share code, notes, and snippets.

View erlangparasu's full-sized avatar

Erlang Parasu erlangparasu

View GitHub Profile
@erlangparasu
erlangparasu / generating_a_csrf_token_php_7.php
Created March 17, 2017 20:27
Generating a CSRF Token (PHP 7)
// https://stackoverflow.com/questions/6287903/how-to-properly-add-csrf-token-using-php/31683058#31683058
// Generating a CSRF Token (PHP 7)
$_SESSION['token'] = bin2hex(random_bytes(32));
What is Cross Site Scripting or XSS?
It simply means: executing abritrary JavaScript code on the page.
Ref: https://css-tricks.com/what-is-xss/
Tag:
* SQL Injection
* XSS - Cross-Site Script Injection
* CSRF - Cross-Site Request Forgery
* Cross-Origin Resource Sharing (CORS)
* JSON with Padding (JSONP)
* The Same-Origin Policy (XHR) XMLHttpRequest
Ref: http://clarkfeusier.com/2015/09/07/browser-security-xss-csrf-injection-safety.html
<!--
How to detect if JavaScript is disabled?
https://stackoverflow.com/questions/121203/how-to-detect-if-javascript-is-disabled/15027965#15027965
(Umesh Patil)
-->
<!DOCTYPE html>
<html lang="en">
<head>
<noscript>
<meta http-equiv="refresh" content="0; /?javascript=false">
<?php
// example: https://localhost/parse_str-example.php?a=123&b=ABC&c=123abc
$queryString = $_SERVER['QUERY_STRING'];
$queryArray = [];
parse_str($queryString, $queryArray);
echo '<pre>';
print_r($queryString);
echo '<pre>';
<!doctype html>
<!--
by: erlangparasu 2017-03-23
-->
<html>
<head>
<meta charset="utf-8">
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style-0.css">
; KeypressOSD.ahk
;--------------------------------------------------------------------------------------------------------------------------
; ChangeLog : v2.22 (2017-02-25) - Now pressing same combination keys continuously more than 2 times,
; for example press Ctrl+V 3 times, will displayed as "Ctrl + v (3)"
; v2.21 (2017-02-24) - Fixed LWin/RWin not poping up start menu
; v2.20 (2017-02-24) - Added displaying continuous-pressed combination keys.
; e.g.: With CTRL key held down, pressing K and U continuously will shown as "Ctrl + k, u"
; v2.10 (2017-01-22) - Added ShowStickyModKeyCount option
; v2.09 (2017-01-22) - Added ShowModifierKeyCount option
; v2.08 (2017-01-19) - Fixed a bug
var foto1 = $('#input_image_1')[0].files[0];
var foto2 = $('#input_image_2')[0].files[0];
var foto3 = $('#input_image_3')[0].files[0];
var foto4 = $('#input_image_4')[0].files[0];
console.log('foto1: ' + foto1);
console.log('foto2: ' + foto2);
console.log('foto3: ' + foto3);
console.log('foto4: ' + foto4);
var formData = new FormData();
formData.append('id_token', mIdToken);
@erlangparasu
erlangparasu / get-last-day-of-month.php
Created April 9, 2017 00:28
Get Last Day Of Month
// Get Last Day Of Month
// Using the modify function it allows you to easily get the last day of the month by simply by writing the words in plain English.
// Ref: https://paulund.co.uk/datetime-php
$date = new DateTime('now');
$date->modify('last day of this month');
echo $date->format('Y-m-d');
// ...
// date time picker must follow modal scroll
$('.ui.dimmer.modals.active').scroll(function () {
var newTop = $('#div_waktu').offset().top + $('#div_waktu').height();
//console.log('top:' + $('#div_waktu').offset().top);
//console.log('height:' + $('#div_waktu').height());
//console.log('newTop:' + newTop);
$('#ui-datepicker-div').css('top', newTop + 'px');
});