Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / imag.less
Created November 5, 2013 22:54
image grayscaled
img {
width: 124px;
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
&:hover {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
-webkit-filter: grayscale(0%);
}
}
@slav123
slav123 / migrate
Created November 17, 2013 04:09
migrate prestashop to new URL
Step1- . Upload all files to new hosting via FTP.
Step2- Database changes ps_configuration table and edit "PS_SHOP_DOMAIN" and "PS_SHOP_DOMAIN_SSL" with the new domain.
Step3- Make the changes in ps_shop_url
Step4- settings.inc.php make the changes as per my Database details.
@slav123
slav123 / is_valid_email.php
Created December 5, 2013 04:09
simple regexp to check if email is valid
<?php
function is_valid_email($email) {
if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0)
return true;
else
return false;
}
@slav123
slav123 / .txt
Created December 9, 2013 03:41
.htaccess redirect to mobile version, with keep urls
RewriteEngine on
RewriteBase /
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:ldn.dev32.info]
# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
# had to check, but I believe most mobile devices should send at
@slav123
slav123 / traverse.js
Created December 25, 2013 00:02
traverse directory structure node.js
var fs = require('fs');
var out;
var args;
/**
* To parse directory structure given a starting point - recursive
*/
function traverseDirectory(startDir, usePath, callback) {
if (arguments.length === 2 && typeof arguments[1] === 'function') {
callback = usePath;
usePath = false;
@slav123
slav123 / bit.php
Created January 4, 2014 12:16
check which version PHP is running
<?php
switch(PHP_INT_SIZE) {
case 4:
echo '32-bit version of PHP';
break;
case 8:
echo '64-bit version of PHP';
break;
default:
echo 'PHP_INT_SIZE is ' . PHP_INT_SIZE;
@slav123
slav123 / vnc.sh
Created January 9, 2014 11:00
enable VNC on mac
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers
@slav123
slav123 / ci-controler.php
Created May 2, 2014 01:34
To get the name of the controller in CodeIgniter:
<?php
$this->router->fetch_class();
$this->router->fetch_method();
@slav123
slav123 / rank-calculations.php
Created May 9, 2014 00:46
nice way to do rankings
<?php
/**
* get leaderboard data
*
* @param int $start starting position
*
* @return array
*/
public function leaderboard($start)
{
#Above solution does not work for me. For me only this one works:
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off [url of website]
Options meaning:
#-r recursive
#-l1 maximum recursion depth (1=use only this directory)
#-H span hosts (visit other hosts in the recursion)
#-t1 Number of retries
#-nd Don't make new directories, put downloaded files in this one