Skip to content

Instantly share code, notes, and snippets.

View johanbrook's full-sized avatar
🌴

Johan Brook johanbrook

🌴
View GitHub Profile
/*
This makes it okay to hook up jQuery plugins in your main JS files
without worrying that they may not be included in the page (if you
perhaps only need this plugin on a few pages – not necessarily globally).
*/
$(function(){
// Do stuff
@johanbrook
johanbrook / Johan-dark.css
Created July 10, 2011 13:35
Quick and dirty styling for the Highlight.js (http://softwaremaniacs.org/soft/highlight/en/) syntax highlighter to match my Textmate theme. Todo: Add Sass support.
/*
Custom style for Wordpress Highlight.js plugin.
By Johan Brook (dark on light colours).
*/
pre code {
color: #c4cdc5;
}
$slide_args = array(
"labels" => $slide_labels,
"public" => true,
"show_ui" => true,
"rewrite" => null,
"cabability_type" => "post",
"description" => __("Slides som syns på förstasidan"),
"supports" => array("title", "custom-fields", "thumbnail")
);
<?php
require_once (SALESFORCE_LIBS_PATH.'/soapclient/SforceEnterpriseClient.php');
require_once (SALESFORCE_LIBS_PATH.'/soapclient/SforceHeaderOptions.php');
class Salesforce_Connection {
protected $connection;
function __construct($loginname, $password){
$this->connection = new SforceEnterpriseClient();
Output:
SimpleXMLElement Object(
[name] => Blah
[price] => Array
(
[0] => 19,31
[1] => 16,39
[2] => 15,65
[3] => 2.12
@johanbrook
johanbrook / gist:1559824
Created January 4, 2012 12:24
Help with arrays and grouping – visual representation
<?php
/*
I have a programming problem I've been pondering over for some time this morning. I want to solve
in an efficient and neat manor, but I honestly haven't got many clues how to think here. Would appreciate
some assistance.
Short description: I want to be able to group nested arrays, and afterwards show this with a separator
or divider when I loop and print the array values.
// Page init code is at the bottom
var Map = (function(map, $){
var exports = map || {};
var geo = new google.maps.Geocoder(),
geocode = {
address: [ config.project_location.street,
config.project_location.city,
config.project_location.country].join(", ")
@johanbrook
johanbrook / gist:1606996
Created January 13, 2012 15:34
Get related posts in Wordpress
function get_related_posts($options = array("numberposts" => 4)) {
global $post;
$defaults = array(
"post__not_in" => array($post->ID)
);
$args = array_merge($options, $defaults);
$tags = wp_get_post_tags($post->ID);
$cats = wp_get_post_terms($post->ID, "category", array("fields" => "ids"));
linkedin: function(json) {
var itemList = [],
template = global.linkedin_template;
$.each(json.post, function(){
var date = new Date(parseInt(this['creation-timestamp'])),
picture = (this.creator['picture-url']) ? this.creator['picture-url'] : "<url till fallback>";
var customData = {