Skip to content

Instantly share code, notes, and snippets.

View mrReiha's full-sized avatar
💥
Digging.

Reiha Hosseini mrReiha

💥
Digging.
View GitHub Profile
@mrReiha
mrReiha / browser.os.regex.php
Last active June 7, 2019 19:37
OS and Browsers' regular expression
<?php
const OS = array(
// Windows
'Windows 10' => 'windows nt 10\.0',
'Windows 8.1' => 'windows nt 6\.3',
'Windows 8' => 'windows nt 6\.2',
'Windows 7' => 'windows nt 6\.1',
'Windows Vista' => 'windows nt 6\.0',

Keybase proof

I hereby claim:

  • I am mrreiha on github.
  • I am mrreiha (https://keybase.io/mrreiha) on keybase.
  • I have a public key ASAuSQLDhuw-gbWfOqtp3ZYsz5bBvxiIuljfKCrWwYi8Ogo

To claim this, I am signing this object:

@mrReiha
mrReiha / terminal.color.style.txt
Created February 21, 2016 09:28
console ( terminal ) style cheatsheet ( from: http://pastebin.com/d0EV14Rd )
# ANSI Start Codes
# Styles.
Normal="\x1b[0m"
Bold="\x1b[1m"
Faint="\x1b[2m"
Italic="\x1b[3m"
Underline="\x1b[4m"
Blink_Slow="\x1b[5m"
Blink_Rapid="\x1b[6m"
@mrReiha
mrReiha / get.windows.size.js
Last active May 1, 2016 11:38
Get windows size ( height & width )( innerHeight & innerWidth ) alternatives
var windowHeight = Math.min( innerHeight || Infinity, screen.availHeight, screen.height );
var windowWidth = Math.min( innerWidth || Infinity, screen.availWidth, screen.width );
@mrReiha
mrReiha / toPersianNumber.js
Last active September 26, 2015 11:18
Convert latin numbers to persian ( arabic ) numbers
/**
* =================================================================================
* Convert latin numbers to persian, and persian numbers to latin
* =================================================================================
*
* @author Reiha Hosseini ( @mrReiha )
* @since 2015/09
*
* @license GPL
*
@mrReiha
mrReiha / fit-img.css
Last active August 29, 2015 14:22
Fit <img> into it's parent
/* It's like background-size: contain; */
.parent img {
max-height: 100%;
max-width: 100%;
}
/* It's like background-size: cover; */
.parent img {
min-height: 100%;
min-width: 100%;
@mrReiha
mrReiha / gist:bc625daf04ed8d2b8ffb
Created March 16, 2015 14:07
Put the caret at the end of input
var putCaretAtEnd = function() {
var range;
if ( typeof this.selectionStart == 'number' )
this.selectionStart = this.selectionEnd = this.value.length;
else if ( typeof this.createTextRange != 'undefined' ) {
this.focus();
@mrReiha
mrReiha / gist:773af8d89d98b0f01452
Created March 3, 2015 09:12
Detect bots by php
if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) )
if ( preg_match( '/bot|spider|curl|crawl/i', $_SERVER[ 'HTTP_USER_AGENT' ] ) )
exit;
@mrReiha
mrReiha / gist:e9e423335ee62097854e
Last active August 29, 2015 14:16
Get ip by php
$ip = isset( $_SERVER[ 'HTTP_X_REAL_IP' ] ) ?
$_SERVER[ 'HTTP_X_REAL_IP' ] : ( isset( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) ?
$_SERVER[ 'HTTP_X_FORWARDED_FOR' ] : $_SERVER[ 'REMOTE_ADDR' ] );
@mrReiha
mrReiha / gist:20121d7f28ac6af320ee
Created March 3, 2015 09:10
Convert encoding of string in SQL's query
SELECT *, CONVERT( CAST( `field` as BINARY ) USING utf8 ) as `coverted_field` FROM `table`