Skip to content

Instantly share code, notes, and snippets.

View erlangparasu's full-sized avatar

Erlang Parasu erlangparasu

View GitHub Profile
@erlangparasu
erlangparasu / xdebug-php.ini
Created February 2, 2017 15:34
xdebug, php, zend, xampp, netbeans
; ...
; Tag: xdebug, php, zend, xampp, netbeans
[XDebug]
zend_extension = "X:/xampp/php/ext/php_xdebug.dll"
zend_extension_ts = "X:/xampp/php/ext/php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "X:/xampp/tmp"
@erlangparasu
erlangparasu / get-the-command-tasklist.bat
Created February 5, 2017 22:09
Get the command tasklist. Tags: windows, cmd, task, tasklist, command, commandline.
:: https://superuser.com/questions/683021/how-to-get-the-command-that-invoked-a-task-with-tasklist/683052#683052
wmic process where caption="test.exe" get commandline,processid
@erlangparasu
erlangparasu / scroll-to-view.java
Created February 3, 2017 08:33
android, scrollview, scroll, view, focus
// ...
/* Scroll to a view */
View view = errorViews.get(0);
View parent = mSvContent;
View parentTemp;
int y = 0;
for (; ; ) {
parentTemp = (View) view.getParent();
y += parentTemp.getTop();
; ...
; Security
;
; The Fast Track to Safe and Secure PHP Sessions
; https://paragonie.com/blog/2015/04/fast-track-safe-and-secure-php-sessions
;
; http://www.slideshare.net/mikestowe/intro-to-php-security-12564855/7-All_it_takes_is_one
;
; Note:
<?php
//
$filepath = 'file.txt';
/**
"htm" => "text/html",
"exe" => "application/octet-stream",
"zip" => "application/zip",
"doc" => "application/msword",
$fio = finfo_open(FILEINFO_MIME_TYPE);
$fif = finfo_file($fio, $path);
$ct = $fif;
$fio = finfo_open(FILEINFO_MIME_ENCODING);
$fif = finfo_file($fio, $path);
$cte = $fif;
//$fn = basename($path);
public class CaUtil {
private static final String TAG = "Tag.CaUtil";
public static String getCaString(Context context) {
try {
/* Get certificate string (for HTTPS connection) */
InputStream caInput = new BufferedInputStream(context.getAssets().open("customCA.crt"));
InputStreamReader inputStreamReader = new InputStreamReader(caInput);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
@erlangparasu
erlangparasu / generate_random_token.php
Created March 17, 2017 11:29
Generate random token in PHP
$length = 32;
$str_bytes = openssl_random_pseudo_bytes($length);
$csrf_token_new = base64_encode($str_bytes);
@erlangparasu
erlangparasu / generate_expires_date_1_day.php
Created March 17, 2017 11:30
Generate expires date (1 day)
/* Generate expires date (1 day) */
$timezone_identifier = 'Asia/Makassar';
date_default_timezone_set($timezone_identifier);
$time = '1 day';
$interval = DateInterval::createFromDateString($time);
$dt = new DateTime();
$dt->add($interval);
$format = 'Y-m-d H:i:s';
$dt_str = $dt->format($format);
@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));