Skip to content

Instantly share code, notes, and snippets.

View de-raaf-media's full-sized avatar

Mark de Raaf de-raaf-media

View GitHub Profile
@de-raaf-media
de-raaf-media / .zshrc
Created February 10, 2021 15:44
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/markderaaf/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@de-raaf-media
de-raaf-media / .zsh_aliases
Last active August 18, 2023 12:13
zsh aliases
# General
alias zshconfig="vim ~/.zshrc"
alias zshreload="source ~/.zshrc"
alias hostfile="sudo vim /etc/hosts"
alias vi="vim"
# Vagrant
alias vu="vagrant up"
alias vp="vagrant provision"
alias vs="vagrant provision"
@de-raaf-media
de-raaf-media / laravel: Controller
Last active January 26, 2018 16:11
Laravel: Default controller
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
/**
@de-raaf-media
de-raaf-media / gist:4721189
Last active December 12, 2015 05:19
Wordpress auto update
$ cd /Users/<username>/Sites
$ sudo chown -R :_www [wordpress directory]
$ sudo chmod -R g+w wordpress directory]
In config file:
define('FS_METHOD', 'direct');
@de-raaf-media
de-raaf-media / gist:4194743
Created December 3, 2012 12:33
simple database operations
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con) or die(mysql_error());
// insert query
@de-raaf-media
de-raaf-media / gist:4135547
Created November 23, 2012 13:09
Show all wordpress queries used
// Add this to your wp-config file:
// Do not leave this enabled on a production environment
define('SAVEQUERIES', true);
//Then, somewhere in your template (probably at the end of the footer.php, add this code:
if (SAVEQUERIES) {
echo "<pre>";
print_r($wpdb->queries);
echo "</pre>";
}
@de-raaf-media
de-raaf-media / gist:4135538
Created November 23, 2012 13:06
wordpress function hook - wp_get_archives by category
// join term_relationships and term_taxonomy
add_filter( 'getarchives_join', 'customarchives_join' );
// add where condition for category
add_filter( 'getarchives_where', 'customarchives_where' );
// add where condition for date
add_filter('getarchives_where','filter_until_year_archives');
function customarchives_join($join_clause) {
global $wpdb;
return $join_clause." INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@de-raaf-media
de-raaf-media / Wordpress functions.php
Created October 29, 2012 15:48
Wordpress functions
// get the the role object
$role_object = get_role( 'editor' );
// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );
@de-raaf-media
de-raaf-media / gist:3857473
Created October 9, 2012 08:52
print_m - formatted print_r
<?php
function print_m($s) {
echo '<pre>';
print_r($s);
echo '</pre>';
}
?>