Skip to content

Instantly share code, notes, and snippets.

Avatar

Joost van Veen joostvanveen

View GitHub Profile
@joostvanveen
joostvanveen / admin.css
Created Jul 29, 2014
The admin.css file for the Getting Started With Laravel 4 Blog
View admin.css
* { font-size: 14px; font-family: helvetica, arial, sans-serif; }
body { margin: 0; padding: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
header { padding: 20px 0; background: #eee; margin-bottom: 20px; }
main { margin-bottom: 20px; }
footer { border-top: 1px solid #ccc; margin: 40px 0; padding-top: 20px; text-align: right; }
.container { max-width: 700px; margin: 0 auto; width: 96%; padding: 0 2%; }
@joostvanveen
joostvanveen / frontend.css
Created Jul 29, 2014
The frontend.css file for the Getting Started With Laravel 4 Blog
View frontend.css
@import url('http://fonts.googleapis.com/css?family=Arvo:400');
@import url('http://fonts.googleapis.com/css?family=Dosis');
body { margin: 0; padding: 0; color: #333; font-size: 18px; font-family: "Dosis", helvetica, arial, sans-serif; font-weight: normal; }
h1, h2, h3 { font-family: "Arvo", helvetica, arial, sans-serif; font-weight: normal; }
h2 a { color: #333; text-decoration: none; }
h2 a:hover, h2 a:active, h2 a:focus { color: #4288CE; text-decoration: none; }
h1 { font-size: 36px; }
h2 { font-size: 28px; }
h3 { font-size: 20px; }
@joostvanveen
joostvanveen / get_key.php
Created Nov 13, 2012
Helper function that returns the value for a key in an array or a property in an object. No more endless isset() statements.
View get_key.php
<?php
/**
* Return the value for a key in an array or a property in an object.
* Typical usage:
*
* $object->foo = 'Bar';
* echo get_key($object, 'foo');
*
* $array['baz'] = 'Bat';
* echo get_key($array, 'baz');
@joostvanveen
joostvanveen / .htaccess
Last active Nov 15, 2015
Canonical redirect in .htaccess - force www. prefix on domain
View .htaccess
# Canonical redirect - force www. prefix on domain
RewriteCond %{HTTP_HOST} ^mydomain\.nl$ [NC]
RewriteRule ^(.*)$ https://www.mydomain.nl/$1 [R=301,L]
@joostvanveen
joostvanveen / get_thumbnail.php
Created Jan 30, 2013
Say I have an image path 'image_path/123.jpg' stored in my database and I need that image's thumbnail, which is in 'image_path/200x200/123.jpg'. Just pass the path and subfolder name to this helper function and it will insert the subfolder in the string.
View get_thumbnail.php
<?php
function get_thumbnail($img_path, $folder = ''){
// Should we just return the given $img_path?
if(empty($folder) || !strstr($img_path, '/')){
return $img_path;
}
// Insert folder name right before image filename
@joostvanveen
joostvanveen / style.css
Last active Dec 14, 2015
CSS file for Tutsplus course Codeigniter Best Practises
View style.css
/* It would be better to reference these Google webfonts directly from your html file */
@import url(http://fonts.googleapis.com/css?family=Molle:400italic);
@import url(http://fonts.googleapis.com/css?family=Droid+Sans);
body {
font-family: "Droid Sans";
font-size: 14px;
line-height: 1.4em
}
@joostvanveen
joostvanveen / magento-sample-data-prefix-script.php
Last active Dec 19, 2015
A simple little script that takes the sample data SQL file for Magento and adds a prefix to it. Make sure to run it before you install the sample data. Also maked sure to specify the same prefix on installing Magento, so your sample data will actually show in the site :) Credit for this script goes to http://ffct.cc/magento-sample-data-prefix-sc…
View magento-sample-data-prefix-script.php
<?php
// your prefix here
$prefix = 'mg4Hk_';
// magento sample data file
// make sure the path to the magento sample data folder is set correctly
$sample_data_path = '../magento-sample-data-1.6.1.0/';
$dumpFile = $sample_data_path . "magento_sample_data_for_1.6.1.0.sql";
@joostvanveen
joostvanveen / gist:7004002
Created Oct 16, 2013
Regex for removing all <span>, <font> and <div> tags from a string. Useful if you wish to edit content from a HTML editor in which somebody accidentally pasted text directly from Word :)
View gist:7004002
<[\/]?(span|font|div)[^>]*>
@joostvanveen
joostvanveen / get-magento-version-number.sh
Created Jan 25, 2016
Get Magento version number from command line
View get-magento-version-number.sh
# Echo Magento version number
cd /path/to/magento/webroot
php -r "include 'app/Mage.php'; echo 'Magento version is: ', Mage::getVersion(); "
@joostvanveen
joostvanveen / remove_big_files-from_git_history.sh
Created Mar 17, 2016
Remove big files from git history to avoid error
View remove_big_files-from_git_history.sh
# This command removes any sql.gz SQL backup file from history, even if it was committed a few commits ago.
# Handy for big files that throw an error when trying to push. As always, rewriting git history is a
# dangerous action! Do not rewrite for commits that have already been fetched by fellow developers.
git filter-branch --prune-empty -d /path/to/tmp/scratch/dir --index-filter "git rm --cached -f --ignore-unmatch *.sql.gz" --tag-name-filter cat -- --all