Skip to content

Instantly share code, notes, and snippets.

View simonkberg's full-sized avatar
:shipit:

Simon Kjellberg simonkberg

:shipit:
View GitHub Profile
<?php
/* Place in /wp-content/ */
include('../wp-config.php');
include('../wp-load.php');
global $wpdb;
//Settings
$type = 0; //1 for post, everything else for pages
$category_id = 1; // ID of the category, or...
_gaq.push(['_trackEvent', thisel.parents('[id!=""]:first').get(0).id, 'clicked', (thisel.text() || thisel.children('img:first').attr('alt'))]);
@simonkberg
simonkberg / OS-Browser_classes.php
Created August 7, 2010 11:58
This PHP function detects which Browser (+version) and OS a user is running and returns or print it in a class-friendly format to use in e.g. Body-class
<?php
//
// This PHP function detects which Browser (+version) and OS a user is running and returns or
// print it in a class-friendly format to use in e.g. Body-class
//
// Use like <?php echo "<body class=\"".OSbodyClass(false)."\">"; ?>
// or <body class="<?php OSbodyClass(); ?>">
//
// example output for Firefox 3.6.8 running on Windows 7: <body class="windows firefox ff3">
@simonkberg
simonkberg / LICENSE.txt
Created June 13, 2011 12:30 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@simonkberg
simonkberg / grid.html
Created July 30, 2012 15:49
CSS-grid Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CSS-grid Generator</title>
<meta name="description" content="The easiest way to construct a basic CSS-grid layout. With query-strings!" />
<meta name="author" content="SimonKberg" />
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
@simonkberg
simonkberg / gist:3878162
Created October 12, 2012 08:54
ffmpeg convert loop
#!/bin/bash
for f in *.mov
do
ffmpeg -i "$f" -s 728x410 -sameq -acodec libmp3lame -aq 0 "../${f%.mov}.mpg"
done
for f in *.mov
do
ffmpeg -i "$f" -s 960x540 -sameq -vprofile baseline -acodec copy "../mov2/${f%.mov}.mov"
@simonkberg
simonkberg / gist:4087491
Created November 16, 2012 13:47
Facebook iFrame check
<?php
// Access with ?dev=true for debugging
$signed_request = isset($_POST['signed_request']) ? $_POST['signed_request'] : false;
$debug = isset($_GET['dev']);
$secret = 'APP_SECRET';
if(!$signed_request && !$debug) {
die('No direct access.');
@simonkberg
simonkberg / gist:5507916
Created May 3, 2013 08:24
MsSQL for Ubuntu
Get dependencies
$ sudo apt-get install php5-sybase freetds-dev php5-dev -y
Move to user hoem directory
$ cd ~
Get php5 source
$ apt-get source php5
Move into the source code directory (substitute x.x with apropritate version number)
@simonkberg
simonkberg / gist:5868471
Last active December 19, 2015 00:28
All tables to InnoDB Convert to UTF8
SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=InnoDB;')
FROM information_schema.tables
WHERE 1=1
AND engine <> 'MyISAM'
AND table_schema NOT IN ('information_schema', 'mysql', 'performance_schema');
SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;')
FROM information_schema.tables
WHERE 1=1
AND collate <> 'utf8_general_ci';
@simonkberg
simonkberg / class-tracking.php.patch
Created July 1, 2013 23:15
Fix for missing wp_users-table error in wp-cron
Index: inc/class-tracking.php
===================================================================
--- inc/class-tracking.php (revision 734869)
+++ inc/class-tracking.php (working copy)
@@ -110,7 +110,7 @@
'name' => get_bloginfo( 'name' ),
'version' => get_bloginfo( 'version' ),
'multisite' => is_multisite(),
- 'users' => $wpdb->get_var( "SELECT COUNT(*) FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1 = 1 AND ( wp_usermeta.meta_key = 'wp_{$blog_id}_capabilities' ) " ),
+ 'users' => $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users AS u INNER JOIN $wpdb->usermeta AS m ON (u.ID = m.user_id) WHERE 1 = 1 AND ( m.meta_key = 'wp_{$blog_id}_capabilities' ) " ),