Skip to content

Instantly share code, notes, and snippets.

@jonesch
jonesch / mail-attachment-wordpress
Created October 22, 2012 12:40
Attaching & Validating A File. Wordpress
if(!empty($_FILES['resume']['name'])){ // check to see if we have a photo and a user clicks submit
$accept_file_formats = array(
'image/jpg',
'image/jpeg',
'image/png',
'image/gif',
'text/rtf', //.rtf file
'text/plain', //.txt file
'application/msword', //.doc file
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', //.docx file
@markstewie
markstewie / gist:5149902
Created March 13, 2013 07:05
A rewrite of the roots_add_rewrites function for the Roots Wordpress framework so that rewrites work when Wordpress is installed in a subdirectory. This function is found in roots/lib/htaccess.php. Once saved, go to the Settings->Permalinks page and things should work.
function roots_add_rewrites($content) {
global $wp_rewrite;
$base = str_replace('/', '', WP_BASE);
if($base != '') $base = $base.'/';
$roots_new_non_wp_rules = array(
$base .'assets/css/(.*)' => $base . THEME_PATH . '/assets/css/$1',
$base .'assets/js/(.*)' => $base . THEME_PATH . '/assets/js/$1',
$base .'assets/img/(.*)' => $base . THEME_PATH . '/assets/img/$1',
$base .'plugins/(.*)' => $base . RELATIVE_PLUGIN_PATH . '/$1'
);
@tomzx
tomzx / gist:aa2d9172a1daef15a0ac
Created January 7, 2015 02:41
./gradlew: Permission denied
/home/travis/build.sh: line 175: ./gradlew: Permission denied
Fix by setting the executable flag on your gradlew file.
Either
chmod +x gradlew (on unix systems)
OR
@ihorvorotnov
ihorvorotnov / wp-get-content
Created February 21, 2014 11:20
WordPress: get post content by ID
/**
* You often need to get the content or title from a specific post.
* Sometimes, using a custom loop is the better option, but when you only need
* to get information from a specific post, there’s a better option
*/
echo get_post_field('post_content', $post_id);
@togramago
togramago / ExtendedNumberPicker.java
Last active May 8, 2019 07:35
NumberPicker with transparent selection dividers via Reflection
package com.runup.myapplication2.app;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.widget.NumberPicker;
import java.lang.reflect.Field;
/**
@keyboardsurfer
keyboardsurfer / .gitignore
Last active December 11, 2019 01:55
Android gitignore
# Copyright: Benjamin Weiss (keyboardsurfer) https://github.com/keyboardsurfer
# Under CC-BY-SA V3.0 (https://creativecommons.org/licenses/by-sa/3.0/legalcode)
# built application files
*.apk
*.ap_
*.jar
!gradle/wrapper/gradle-wrapper.jar
# lint folder
@viitechsolutions
viitechsolutions / install-xdebug.sh
Created April 29, 2020 18:36
Install xdebug on Mac or Linux
curl https://xdebug.org/files/xdebug-2.9.5.tgz --output xdebug-2.9.5.tgz
tar -xzf xdebug-2.9.5.tgz
cd xdebug-2.9.5
phpize
./configure --enable-xdebug
make
make install
@bucker
bucker / bash_shortcut.md
Last active May 16, 2021 17:31
Bash shortcuts for Mac

To Use the option (⌥) key, set it as meta key

Moving the cursor

  • ⌃a: Go to the beginning of the line
  • ⌃e: Go to the end of the line
  • ⌃p: Previous command (Up arrow)
  • ⌃n: Next command (Down arrow)
  • ⌃f: Forward one character
  • ⌃b: Backward one character
  • ⌃xx: Toggle between the start of line and current cursor position
@dcnl1980
dcnl1980 / nginx-cookieless.conf
Last active September 17, 2021 02:48
Nginx Cookieless Domain
#
# Name: nginx-cookieless.conf
# Auth: Chris van Steenbergen <cvsteenbergen@gmail.com>
# Date: 12 August 2016
# Desc: Nginx Cookieless Domain configuration for 100% performance grade with
#
# See for yourself at: https://tools.pingdom.com/#!/beJG0v/http://www.reclick.nl
#
server {
@tamoyal
tamoyal / gist:10441108
Created April 11, 2014 04:39
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile