Skip to content

Instantly share code, notes, and snippets.

View qutek's full-sized avatar
💻
Working from home

Lafif Astahdziq qutek

💻
Working from home
View GitHub Profile
@qutek
qutek / Default (OSX).sublime-keymap
Created April 6, 2015 09:32
[Mac] Linux sublime keymap for OSX
/*
Replace default osx keymap, or just add this to Preferences -> Key Bindings -> User
*/
[
{ "keys": ["ctrl+q"], "command": "exit" },
{ "keys": ["ctrl+shift+n"], "command": "new_window" },
{ "keys": ["ctrl+shift+w"], "command": "close_window" },
{ "keys": ["ctrl+o"], "command": "prompt_open_file" },
{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" },
@qutek
qutek / gist:a700c5b8b231e99c1d07
Last active November 29, 2015 20:25 — forked from saetia/gist:1623487
OSX Preference

OS X Preferences


#Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false

#Enable repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
@qutek
qutek / functions.php
Created March 5, 2015 07:49
[Wordpress] Allow user login with email
<?php
/**
* login_with_email filter to the authenticate filter hook, to fetch a username based on entered email
* @param obj $user
* @param string $username [description]
* @param string $password [description]
* @return boolean
*/
add_filter('authenticate', 'login_with_email', 20, 3);
@qutek
qutek / functions.php
Created March 2, 2015 08:46
[Wordpress] Function to get all post from category slug with wpdb
function _getPostByCategory($post_type, $category_slug){
global $wpdb;
$query = "SELECT p.*, terms.term_taxonomy_id, terms.term_id, terms.slug, terms.name from $wpdb->posts p INNER JOIN
( SELECT rel.object_id , rel.term_taxonomy_id, term.term_id, term.name, term.slug FROM $wpdb->term_relationships rel
INNER JOIN (SELECT ttax.term_taxonomy_id, ttax.term_id, t.name, t.slug FROM $wpdb->term_taxonomy ttax
INNER JOIN $wpdb->terms t ON t.term_id = ttax.term_id
) term
ON rel.term_taxonomy_id = term.term_taxonomy_id ) terms
ON p.ID = terms.object_id
@qutek
qutek / terminal.sh
Created February 20, 2015 11:13
[Server][Git] Fixing git-receive-pack: command not found
## Run on server
alias git-receive-pack="/usr/local/cpanel/3rdparty/bin/git-receive-pack"
## I still need to add it to my ~/.bashrc
export PATH=$PATH:"/usr/local/cpanel/3rdparty/bin"
## Also, on a side note the whole stdin: is not a TTY error can be fixed by removing the /home/git/.bashrc file.
@qutek
qutek / .htaccess
Created February 4, 2015 11:48
[server] Rewrite old domain to new domain
#rewrite all subdomain on old domain to subdomain on new domain
RewriteCond %{HTTP_HOST} ^(.*)\.olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://%1.newdomain.com/$1 [R=301,L]
# rewrite all links to new domain
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
@qutek
qutek / backup.sh
Created January 28, 2015 10:01
[shell] Script to backup mysql databases with split
#!/bin/bash
### change the values below where needed.....
### taken from http://moinne.com/blog/ronald/mysql/backup-large-databases-with-mysqldump
DBNAMES="MyDb1 MyDb2 MyDb3"
HOST="--host=localhost"
USER="--user=root"
PASSWORD="--password=MyPassword"
BACKUP_DIR="/MyBackupDirectory"
#### you can change these values but they are optional....
@qutek
qutek / functions.php
Last active March 15, 2016 00:01
[Wordpress][Buddypress] Add new menu item buddypress profile
<?php
function custom_bp_nav() {
global $bp;
bp_core_new_nav_item(
array(
'name' => __( 'Site Settings', 'buddypress' ),
'slug' => 'site-settings',
'position' => 80,
'screen_function' => 'site_settings_screen',
@qutek
qutek / strtr_replace.php
Created November 24, 2014 05:52
[PHP] Replace string to variable with pattern
<?php
/**
* Replace string with pattern
* (example use: for mail templating)
*
* @codes array();
* @pattern string;
*/
$message = 'coba username {username} atau {user_email}';
@qutek
qutek / site_options.php
Last active August 29, 2015 14:10
[Wordpress] Sample options page
<?php
/**
* _s Theme Options
*
* @package _s
* @since _s 1.0
*/
/**
* Register the form setting for our _s_options array.