Skip to content

Instantly share code, notes, and snippets.

View hamidreza-s's full-sized avatar

Hamidreza Soleimani hamidreza-s

View GitHub Profile
<?php
// Class
$reflector = new ReflectionClass('FooClass');
// Class methods
/*
array(43) {
[0] => string(6) "export"
[1] => string(11) "__construct"
@hamidreza-s
hamidreza-s / Batch - TCP Opening Ports.bat
Created January 8, 2013 09:16
In Windows Command line we can use this command to list TCP opening port with their PID.
netstat -ano -t tcp
@hamidreza-s
hamidreza-s / PHP - Hide X-Powered-By.ini
Created January 8, 2013 12:21
Hide X-Powered-By field name from HTTP Response. Go to expose_php directive in php.ini file and set it to Off.
expose_php = Off
@hamidreza-s
hamidreza-s / Bash - TCP Opening Ports.sh
Last active December 10, 2015 20:59
It finds listening IP, Port, and corresponding Programs.
# -n, --numeric
# -t, --tcp
# -l, --listening
# -p, --protram
# -a, --all
netstat -ntlpa
@hamidreza-s
hamidreza-s / Bash - Lists Running Processes.sh
Created January 9, 2013 10:17
It lists all process with their tree. Especially used for show nginx worker processes.
# f, --forest (ASCII art process tree)
ps faux
@hamidreza-s
hamidreza-s / cURL - Get HTTP Header.sh
Created January 12, 2013 13:33
It responds the HTTP Header of the specified URL
curl -I url
# or
curl --head url
@hamidreza-s
hamidreza-s / jQuery - this vs e.currentTarget.js
Last active December 11, 2015 01:19
Seems like they are equivalent in most cases, though "this" seems easier to type.
// 1, this
$('#selector').on('click',function(){
$(this)...
// do stuff with clicked element
})
// 2, e.currentTarget
$('#selector').on('click',function(e){
$(e.currentTarget)....
// do stuff with clicked element
@hamidreza-s
hamidreza-s / Shell - File Descriptor.sh
Created January 15, 2013 12:13
File descriptor - An integer that identifies an open file within a process. This number is obtained as a result of opening a file. Operations which read, write, or close a file would take the file descriptor as an input parameter. In many operating system implementations, file descriptors are small integers which index a table of open files. In …
# 0, Standard input (stdin) <0
# 1, Standard output (stdout) 1>
# 2, Standard error (stderr) 2>
# Examples:
# redirect stderr (2) to stdout (1)
2>&1
@hamidreza-s
hamidreza-s / PHP - List Directory.php
Created January 15, 2013 20:15
List directory file/folder with PHP and create an array of them, then calculate their Character Code.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
</head>
<body>
<?php
// shell command
$list = shell_exec('ls');
@hamidreza-s
hamidreza-s / MySQL - Import CSV.sql
Created January 22, 2013 07:19
Instead of writing a script to pull in information from a CSV file, you can link MYSQL directly to it and upload the information using the following SQL syntax. To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV …
# Create Table
CREATE TABLE IF NOT EXISTS `foo_table` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`bar_column` varchar(10) NOT NULL,
`bat_column` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Load Data
load data local infile '/path/to/file.csv' into table `foo_table`