This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Read file line-by-line from given byte offset. | |
* Handy for re-processing large logs files. | |
*/ | |
// Filename to use for temporary data | |
define('DATA_FILE', 'data.log'); | |
// Create the data file on the fly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/** | |
* Use the same script for different purposes, based on the | |
* name of the file being called (symlinks). | |
* | |
* Install: chmod +x symlink.php && ln -s another-symlink.php b.php | |
* Run: ./symlink.php --with A params && ./another-symlink.php --with B params | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$charts = array( | |
'live1-ajax-total-count' => array( | |
'type' => 'line', | |
'title' => 'LIVE1 Total Count (ajax)', | |
'sql' => 'select .... ', | |
'callback' => 'minute_counts', | |
), | |
'live2-ajax-total-count' => array( | |
'type' => 'line', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
<?php | |
define('DEFAULT_LANGUAGE', 'en'); | |
$lang = !empty($_REQUEST['lang']) ? $_REQUEST['lang'] : DEFAULT_LANGUAGE; | |
$translations = get_translations($lang); | |
if (!empty($translations)) { | |
foreach ($translations as $key => $value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/usr/sbin/ntpdate -s 0.fedora.pool.ntp.org | |
/usr/sbin/ntpdate -s 1.fedora.pool.ntp.org | |
/usr/sbin/ntpdate -s 2.fedora.pool.ntp.org | |
/sbin/hwclock -w |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOMAIN="easyforex" | |
POT="$DOMAIN.pot" | |
LANGS="en_US ru_RU" | |
SOURCES="*.php" | |
# Create template | |
echo "Creating POT" | |
rm -f $POT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# | |
# Encoding URLs for XML, using regular expressions | |
# | |
# XML string | |
$string = '<page>some&page</page><page>some&otherpage</page><page>yet&anotherpage</page>'; | |
$result =preg_replace_callback( | |
'#(<page>(.*?)</page>)#', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example of sprintf()/vsprintf() with gettext | |
*/ | |
/** | |
* String translation | |
* | |
* @param string $param String to translate | |
* @return string Translated string (surrounded by square brackets for visibility) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a test of Gist vim plugin. | |
Hopefully, this will end up in my gists. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace middle of the string with given char, keeping length | |
* | |
* <code> | |
* print padString('1234567890123456', 0, 0, 'x'); | |
* </code> | |
* | |
* @param string $string String to process | |
* @param integer $start Characters to skip from start |