Skip to content

Instantly share code, notes, and snippets.

View ganicus's full-sized avatar

Ganicus Magnus ganicus

View GitHub Profile
enum Router: URLRequestConvertible {
static let baseURLString = "http://dev.example.com"
static var OAuthToken: String?
case MapView(Int)
case PhotoInfo(Int, ImageSize)
case Comments(Int, Int)
var URLRequest: NSURLRequest {
let (path: String, parameters: [String: AnyObject]) = {
@ganicus
ganicus / Wordpress: Multiple Post Upload From Other Database
Created May 31, 2012 17:40
Wordpress: Multiple Post Upload File
<?php
/*
Template Name: MaxDebug
*/
// Get WP
include_once"wp-config.php";
include_once"wp-load.php";
include_once"wp-includes/wp-db.php";
//Connect To Old Database
$oldbros = new wpdb('root','Catalin@2040','sqlbros','localhost');
@ganicus
ganicus / Wordpress: Custom Post url_postid
Created May 5, 2012 04:10
Wordpress Function For Getting Custom Posts IDs From Their URLs
<?php
/* Post URLs to IDs function, supports custom post types - borrowed and modified from url_to_postid() in wp-includes/rewrite.php */
function bwp_url_to_postid($url)
{
global $wp_rewrite;
$url = apply_filters('url_to_postid', $url);
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) {
@ganicus
ganicus / .htaccess: Header Buffering
Created May 2, 2012 18:55
PHP Header Buffering For .htaccess File To Prevent "Header already sent" Errors
# Header Buffering
php_flag output_buffering on
@ganicus
ganicus / Wordpress: Tax-Term Posts Lists
Created April 22, 2012 20:25
Wordpress: Tax-Terms Posts List
<div id="list123">
<?php
// List posts by the terms for a custom taxonomy of any post type
$post_type = 'YOUR_POST_TYPE';
$tax = 'YOUR_TAXONOMY';
$tax_terms = get_terms( $tax );
if ($tax_terms) {
@ganicus
ganicus / Shell: Find and Delete Sed
Created March 19, 2012 19:22
Shell: Find and Delete Using Sed
find . -name "*.php" -type f -exec sed -i '/eval(base64_decode(/d' {} \;
@ganicus
ganicus / gist:1991295
Created March 7, 2012 05:38
Text: Test
This is a test