This file contains 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
Test date format:<br> | |
En: {234234|date_format:'%B %e, %Y'}<br> | |
Rus: {234234|date_format:'%e %m %Y':'':'rus'}<br> | |
Urk: {234234|date_format:'%e %m %Y':'':'ukr'}<br> | |
First parameter - php.net/strftime (%m is changed to 'января':'декабря' for Russian and 'ciчня':'грудня' for Ukrainian) | |
Second parameter - default date (if argument == '') | |
Third - 'auto', 'rus', 'ukr' | |
Works with 0F modified date_format Smarty plugin. It's below in this gist: modifier.date_format.php |
This file contains 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
// cart.js | |
// | |
// Copyright 2014 Jeka Kiselyov | |
// Released under the MIT license, http://opensource.org/licenses/MIT | |
// | |
// Usage: | |
// Cart.add(sku, name, 9.99, qty); | |
// Cart.remove(sku); | |
// if (Cart.has(sku)) { ... | |
// var price = Cart.priceTotal(); |
This file contains 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
/// Always forget it | |
/// Source: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm | |
relativeError = fabs((result - expectedResult) / expectedResult); | |
// If result is 99.5, and expectedResult is 100, then the relative error is 0.005. | |
// Sometimes we don’t have an ‘expected’ result, we just have two numbers that we want to compare to see if they are almost equal. // We might write a function like this: | |
// Non-optimal AlmostEqual function - not recommended. |
This file contains 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 | |
//// | |
//// Usage: php backup_to_pbworks.php network workspace apikey | |
//// | |
//// Archives uploads folder and mysql database and saves it in pbworks workspace | |
//// | |
require "includes/cron_init.php"; //// You can change this to any init you want. | |
/// Basically we need only __db_database__, __db_host__ etc params from settings/db.php | |
/// But you can easily use your own values few lines below and remove this require |
This file contains 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/sh | |
echo "Updating devtest area"; | |
echo "Enter your git credentials below:"; | |
cd ~/domain/ | |
git pull | |
cd ../ | |
/usr/local/php53/bin/php ~/domain/www/cli/tools/update_schema.php |
This file contains 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
var l = document.getElementsByClassName('img'); for (var k in l) if (typeof(l[k].onmouseover) == 'function') l[k].onmouseover(); | |
var els = document.getElementsByClassName('search_bigph'); | |
var cur_els = 0; | |
setTimeout(next_cur_el, 5000); | |
function next_cur_el() | |
{ | |
if (typeof(els[cur_els]) == 'undefined') return; | |
els[cur_els].click(); | |
var r1 = Math.random() * (3000 - 500) + 500; | |
var r2 = Math.random() * (5000 - 2000) + 2000 + r1; |
This file contains 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
SetEnv localhost localhost | |
ServerName localhost | |
Mutex file:${APACHE_LOCK_DIR} default | |
PidFile ${APACHE_PID_FILE} | |
Timeout 300 |
This file contains 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 | |
run() | |
{ | |
echo "Adding new apache domain" | |
if [ "$(id -u)" != "0" ]; then | |
echo "Sorry, but this script should be executed by root only. Try: sudo ./add_apache_domain.sh" | |
return | |
fi |
This file contains 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 | |
//// usage - php backup.php domain | |
$network = 'network'; | |
$workspace = 'workspace'; | |
$apikey = '...........'; | |
$tmp_path = sys_get_temp_dir(); //// should be writable | |
define( 'ABSPATH', dirname(__FILE__) . '/' ); | |
//// create empty wp-settings.php file (wp config tries to find it) |
This file contains 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
////// Save as index.js and upload it to Lambda as zip archive with node_modules directory. After: | |
////// npm install aws-cloudwatch-chart | |
////// npm install request | |
////// no need to upload aws-sdk module | |
////// Don't forget to change API keys here. | |
////// License: MIT | |
////// Docs: |
OlderNewer