Skip to content

Instantly share code, notes, and snippets.

View egulhan's full-sized avatar
Here we go again...

Erman Gülhan egulhan

Here we go again...
View GitHub Profile
@egulhan
egulhan / es-query-examples.txt
Created July 15, 2014 10:31
Elastic Search quey examples
$filteredQuery=array(
'filtered'=>array(
'query'=>array(
'query_string'=>array('query'=>'enveloperecipients:*@domain.com* AND result:0 AND NOT remoteip:10.1.1.*')
),
'filter'=>array(
'range'=>array(
'recvtime'=>array('from'=>'2013-07-01','to'=>'2013-07-31')
)
),
@egulhan
egulhan / xs.js
Last active August 29, 2015 14:04
Roundcube notes
// Get current language
$_rcmail->config->get('language');
//
@egulhan
egulhan / get-query-variable.js
Created July 24, 2014 09:17
How-to get URL variables using JavaScript
/**
Usage
Example URL:
http://www.example.com/index.php?id=1&image=awesome.jpg
Calling getQueryVariable("id") - would return "1".
Calling getQueryVariable("image") - would return "awesome.jpg".
*/
@egulhan
egulhan / ResizeImage.php
Created July 24, 2014 13:56
Resize Image Class With PHP
<?php
// @source: http://www.paulund.co.uk/resize-image-class-php
/**
* Resize image class will allow you to resize an image
*
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio
@egulhan
egulhan / forceToDownload.php
Created July 24, 2014 13:57
Force to download file using PHP
<?php
// @source: http://www.paulund.co.uk/force-download-of-files-in-php
function downloadFile($file){
$file_name = $file;
$mime = 'application/force-download';
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
@egulhan
egulhan / keyboard-key.css
Last active August 29, 2015 14:05
Keyboard key expression in HTML
kbd {
padding: .1em .6em;
border: 1px solid #ccc;
font-size: 11px;
font-family: Arial,Helvetica,sans-serif;
background-color: #f7f7f7;
color: #333;
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;
-webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;
box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;
@egulhan
egulhan / getExtIP.sh
Created August 9, 2014 19:32
Learn external IP on CLI
# Add this func. to your .bashrc
function ext-ip () { curl http://ipecho.net/plain; echo; }
@egulhan
egulhan / check-startup-services.sh
Created August 20, 2014 13:57
How-to check services which are enabled at boot
$ chkconfig --list | grep $(runlevel | awk '{ print $2}'):on
@egulhan
egulhan / function.removeNonAsciiChars.php
Created August 23, 2014 16:13
Remove non-ascii characters using PHP
function removeNonAsciiChars($str)
{
return preg_replace('/[[:^print:]]/','',$str);
}
@egulhan
egulhan / down-arrow.css
Created August 27, 2014 07:27
Down arrow with just CSS
.caret{
/* down-arrow begin */
display: inline-block;
width: 0;
height: 0;
vertical-align: middle;
border-top: 4px solid #000000;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
content: "";