Skip to content

Instantly share code, notes, and snippets.

View jasperf's full-sized avatar
🏠
Working from home

Jasper Frumau jasperf

🏠
Working from home
View GitHub Profile
@jasperf
jasperf / curl-get-headers
Last active December 14, 2015 01:59
cURL Get Headers #curl #http
curl -I -L domain.com
@jasperf
jasperf / custom-post-type-custom-taxonomy-title
Created March 20, 2013 08:46
Custom Post Type Custom Taxonomy Title: This code loads the title of the current CPT category or the taxonomy page title. Source of the snippet is mentioned in code below
//http://wordpress.org/support/topic/taxonomy-title-output?replies=7 slambert
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
@jasperf
jasperf / gzip-sites
Created March 26, 2013 04:59
Gzip and Gunzip a whole site from the command line
//Gzip a site on the server as a backup
tar -zcvf domain.com.tar.gz /home/jasper/domain.com
//Gunzip a gzipped tar file
tar -zxvf domain.com.tar.gz
@jasperf
jasperf / deactivate-all-plugins
Last active December 15, 2015 14:29
Disable all plugins in WordPress using PHP Admin or a MySQL Client (included query to show all active plugins)
// To find all active plugins
SELECT * FROM wp_options WHERE option_name = 'active_plugins';
// Then remove all code indicating which plugins are active and save again
@jasperf
jasperf / phprc
Last active December 15, 2015 14:29
Custom PHP RC File in Dreamhost to show PHP errors for one user #dreamhost #PHP #phprc
//In /home/username/.php/5.3
//and a file called "phprc" with following content - 2 rows only which is to be found in above folder:
//log_errors = 1
//error_log = /home/user/php_errors.txt
cd /home/user
mkdir .php && cd .php
mkdir 5.3
cd 5.3
nano phprc
//add the lines
@jasperf
jasperf / cp-domain-files-to-other directory
Last active December 16, 2015 03:29
Copy (WordPress) site from root domain to subdomain under same user #wordpress #unix #copy
//Go into the the folder containing all files in the root domain
//Enter the following command assuming both domains are in the same
//user folder like at Dreamhost and most hosters
//http://forums.devshed.com/linux-help-33/how-to-copy-all-content-of-a-directory-26094.html
cp -R * ../sub.domain.com/
@jasperf
jasperf / trac-resynch
Created April 19, 2013 03:37
Fix Trac after SVN Repo location change causing error:Warning: Can't synchronize with the repository (The 'repository_dir' has changed, a 'trac-admin resync' operation is needed.). Look in the Trac log for more information.Bumped into this deleting one flawed repo and creating a new one. I changed trace.ini to load the new repo, but then got thi…
trac-admin /home/username/trac.domain.com/new-repo-name resync
@jasperf
jasperf / php-chmod
Created June 11, 2013 10:05
PHP Script to change file and folder permissions See http://www.webhostingtalk.com/showthread.php?t=218863 #PHP #permissions #chmod
<?php
//http://www.webhostingtalk.com/showthread.php?t=218863
$start_dir = 'whatever'; // Starting directory no trailing slashes.
$perms['file'] = 0644; // chmod value for files don't enclose value in quotes.
$perms['folder'] = 0755; // chmod value for folders don't enclose value in quotes.
function chmod_file_folder($dir) {
global $perms;
$dh=@opendir($dir);
@jasperf
jasperf / replace-wp-post-content-if-not-null
Last active December 18, 2015 17:39
Replace WordPress content in posts when the post is not empty using a MySQL query. This I sometimes use to replace dummy content with Lorem Ipsum content to make it easier for clients to focus on the layout and style and not so much on the text, #wordpress #posts
//NB Replace wp with your own prefix
//see http://stackoverflow.com/questions/17099905/replace-old-wordpress-post-content-with-new-if-not-empty
//For Lorem Ipsum Content see http://www.blindtextgenerator.com/lorem-ipsum
UPDATE wp_posts SET post_content = 'NewText' WHERE post_content > ''
@jasperf
jasperf / remove-password-excell
Created July 1, 2013 05:37
Hack Excell Workbook password and thereby remove the protection it has//http://www.mcgimpsey.com/excel/removepwords.html #excell #hacks #security
Public Sub AllInternalPasswords()
' Breaks worksheet and workbook structure passwords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of workbook structure / windows passwords and for multiple passwords
'
' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
' Modified 2003-Apr-04 by JEM: All msgs to constants, and
' eliminate one Exit Sub (Version 1.1.1)
' Reveals hashed passwords NOT original passwords
Const DBLSPACE As String = vbNewLine & vbNewLine