Skip to content

Instantly share code, notes, and snippets.

@forsvunnet
forsvunnet / SH: git alias pretty format.sh
Last active December 18, 2015 00:29
Provides pretty format for git functions (NB! Prints directly to stdout)
function gt (){
if [[ $# > 1 ]]; then
g $1 --pretty=format:'%Cblue%h%Creset - %Cred%s %Cgreen(%cr)%Cblue <%an>%Creset' ${*:2} | cat -
else
echo "Usage: gt [git_function] *"
fi
}
#Make a new branch:
gco -b new_branch
#do bunch of changes
ga -A
gc -m "Made a bunch of changes"
#checkout master
gco master
#get the latest updates to master
gl
#Go back to new_branch or whatever you called it
@forsvunnet
forsvunnet / PHP WP: auto email filter.php
Created September 9, 2013 12:44
A filter to automatically link email addresses in a spam-safe manner
<?php
function driv_auto_email($text) {
$matches = array();
if (preg_match('/[A-Za-z\.\-\_]*@[A-Za-z\-\_]*\.[A-Za-z\.]*/', $text, $matches)) {
foreach ($matches as $match) {
$email = '';
$chars = array();
for ($i=0, $len = strlen($match); $i < $len; $i++) {
@forsvunnet
forsvunnet / SH: wordpress_download.sh
Created September 24, 2013 15:59
A script to download and install wordpress in the provided folder. Will exit if the folder exists. Copy paste to aliases dot-file
function wpdl(){
if [[ -d ./${1} ]]; then
echo "Project directory exists, exiting..."
elif [[ $# = 1 ]]; then
mkdir $1
cd $1
curl -O http://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
mv wordpress/* ./
// A function to strip unit type from numbers
@function strip-units($number) {
@return $number / ($number * 0 + 1);
}
// A mixin to remify a property
@mixin rem($prop, $data) {
$len: length($data);
$px_list: null;
@forsvunnet
forsvunnet / SCSS: pretty-colours.scss
Last active December 27, 2015 04:09
A few pretty colours.
$yellow-light: #FFF8DC;
$yellow-dark: #840;
$green-light: #EEE8AA;
$green-dark: #234600;
$red-light: #FFE4E1;
$red-dark: #8c2e0b;
<?php
/*
Plugin Name: ${PLUGIN_NAME}
Plugin URI: http://www.barrykooij.com/${CLASS_NAME}
Description: ${PLUGIN_DESC}
Version: 1.0.0
Author: Barry Kooij
Author URI: http://www.barrykooij.com/
*/
@forsvunnet
forsvunnet / WP: .gitignore
Created March 27, 2014 10:38
A list of common files to ignore in a wordpress git setup
*.codekit
.htaccess
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
wp-content/themes/twenty*
sitemap.xml
@forsvunnet
forsvunnet / equalise-usage.js
Last active August 29, 2015 14:05
Equalise usage
// jQuery Closure mode
(function($){
// Resizing the propper way
var resize = function() {
$('element').equalise();
};
$(window)
.ready( resize )
.load( resize )
<?php /* This changes the CSV into another CSV. But merges duplicated fields. */
$fh = fopen("clubexp.csv", "r");
$row = 0;
$clubs = array();
while (($data = fgetcsv($fh, 1000, ",")) !== FALSE) {
// ID
$club_id = $data[0];
// Day