Skip to content

Instantly share code, notes, and snippets.

View jayarjo's full-sized avatar
👻
Here, but elsewhere.

Davit Barbakadze jayarjo

👻
Here, but elsewhere.
View GitHub Profile
@jayarjo
jayarjo / Chunking: server-side
Created June 23, 2013 21:38
Plupload Examples: Chunking
<?php
if (empty($_FILES) || $_FILES['file']['error']) {
die('{"OK": 0, "info": "Failed to move uploaded file."}');
}
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : $_FILES["file"]["name"];
@jayarjo
jayarjo / Chunking: client-side
Last active August 26, 2019 13:56
Plupload Examples: Chunking
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload - Getting Started: Chunking</title>
<script type="text/javascript" src="js/plupload.full.min.js"></script>
</head>
@jayarjo
jayarjo / Getting Started 01
Last active August 21, 2016 08:58
Plupload Examples: Getting Started
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload - Getting Started</title>
<script type="text/javascript" src="js/plupload.full.min.js"></script>
</head>
#!/bin/bash
sudo apt-get install -y --force-yes apache2
sudo a2enmod actions
sudo a2enmod rewrite
echo "export PATH=/home/vagrant/.phpenv/bin:$PATH" | sudo tee -a /etc/apache2/envvars > /dev/null
echo "$(cat scripts/travis/assets/phpconfig.txt)" | sudo tee /etc/apache2/conf.d/phpconfig > /dev/null
echo "$(cat scripts/travis/assets/vhost.txt)" | sed -e "s,PATH,`pwd`/web,g" | sudo tee /etc/apache2/sites-available/default > /dev/null
echo "date.timezone = UTC" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
sudo service apache2 restart
language: php
php:
- 5.3
- 5.4
before_script:
- sudo apt-get install apache2
- sudo a2enmod actions
- sudo a2enmod rewrite
language: php
php:
- 5.3
- 5.4
before_script:
- sudo apt-get install apache2
- sudo a2enmod actions
- sudo a2enmod rewrite
language: php
php:
- 5.3
- 5.4
before_script:
- sudo apt-get install apache2
- sudo a2enmod actions
- sudo a2enmod rewrite
@jayarjo
jayarjo / gist:5232728
Created March 24, 2013 17:25
make base color darker by a specified factor
function hex_darker($hex, $factor = 30)
{
$new_hex = '';
$base['R'] = hexdec($hex{0}.$hex{1});
$base['G'] = hexdec($hex{2}.$hex{3});
$base['B'] = hexdec($hex{4}.$hex{5});
foreach ($base as $k => $v)
{
@jayarjo
jayarjo / gist:5186403
Created March 18, 2013 10:54
truncate text to a specific word length
function truncate($text, $length, $more = '...')
{
$text = strip_shortcodes( $text );
//$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]&gt;', $text);
$text = strip_tags($text);
$words = explode(' ', $text, $length + 1);
if (count($words) > $length) {
array_pop($words);
@jayarjo
jayarjo / gist:4721061
Last active December 12, 2015 05:19
redirect non-www to www
# ignore specific path (/administrator/ - in this case)
RewriteCond %{REQUEST_URI} ^/?administrator($|\/|\/.*) [NC]
RewriteRule ^.*$ - [NC,L]
# redirect non-www to www
RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]