Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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

saasfreelancer saas786

🏠
Working from home
View GitHub Profile
@saas786
saas786 / namespace.js
Created April 14, 2012 11:24 — forked from colingourlay/namespace.js
JavaScript: namespacing (depends on jQuery)
(function (global, $) {
global.namespace = function (nsName, obj) {
var level, names, name;
level = global;
names = nsName.split('.');
while(name = names.shift()) {
level[name] = level[name] || {};
level = level[name];
}
$.extend(level, obj);
@saas786
saas786 / jwplayer_metabox.php
Created April 17, 2012 06:52 — forked from ramseyp/jwplayer_metabox.php
How do display JWPlayer shortcode from custom meta box
<?php
/*
* The JW Player plugin drops shortcode into the editor. It's not filtered through WordPress's do_shortcode().
* You need to use jwplayer_tag_callback().
*/
global $post;
if (get_post_meta($post->ID, '_cmb_mini_wysiwyg', true) ):
$myvid = get_post_meta($post->ID, '_cmb_mini_wysiwyg', true);
$myvid = jwplayer_tag_callback( $myvid );
echo $myvid;
@saas786
saas786 / gist:2516910
Created April 28, 2012 07:38 — forked from josper0544/gist:2516564
IE Detect Script
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@saas786
saas786 / dabblet.css
Created April 28, 2012 07:45 — forked from illnino/dabblet.css
No space between inline-block
body {
font-family: sans-serif;
}
ul {
list-style: none
}
a{
text-decoration: none;
@saas786
saas786 / ajax-other-domains.js
Created April 28, 2012 07:46 — forked from agarie/ajax-other-domains.js
Sending AJAX requests to other domains
/*
Used when you need a JSON feed from your other domain. Need a
Content-type of application/json, so be sure to use the correct
HTTP header in your app (at the other domain).
*/
// blabla just don't forget jQuery
$.ajax({
url: "another domain generating a JSON",
{"nodes":[{"name":"Myriel","group":1},{"name":"Napoleon","group":1},{"name":"Mlle.Baptistine","group":1},{"name":"Mme.Magloire","group":1},{"name":"CountessdeLo","group":1},{"name":"Geborand","group":1},{"name":"Champtercier","group":1},{"name":"Cravatte","group":1},{"name":"Count","group":1},{"name":"OldMan","group":1},{"name":"Labarre","group":2},{"name":"Valjean","group":2},{"name":"Marguerite","group":3},{"name":"Mme.deR","group":2},{"name":"Isabeau","group":2},{"name":"Gervais","group":2},{"name":"Tholomyes","group":3},{"name":"Listolier","group":3},{"name":"Fameuil","group":3},{"name":"Blacheville","group":3},{"name":"Favourite","group":3},{"name":"Dahlia","group":3},{"name":"Zephine","group":3},{"name":"Fantine","group":3},{"name":"Mme.Thenardier","group":4},{"name":"Thenardier","group":4},{"name":"Cosette","group":5},{"name":"Javert","group":4},{"name":"Fauchelevent","group":0},{"name":"Bamatabois","group":2},{"name":"Perpetue","group":3},{"name":"Simplice","group":2},{"name":"Scaufflaire","group":2},
@saas786
saas786 / gist:2516959
Created April 28, 2012 07:49 — forked from michaeltwofish/gist:2515912
Left join query
SELECT *, count(client_tests.id) AS test_count FROM clients LEFT JOIN client_tests ON clients.id = client_tests.client_id GROUP BY clients.id;
@saas786
saas786 / apache-access-log-parser.rb
Created April 28, 2012 07:54 — forked from agilous/apache-access-log-parser.rb
Apache access log parser
#!/usr/bin/env ruby
# Helpful link: http://httpd.apache.org/docs/2.4/logs.html
require 'date'
line_count = 0
File.open(ARGV[0]).readlines.each do |line|
line_count += 1
result = /^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*\[(.*)\].*(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT)\s(.*)\"\s(\d+)\s(\d+)(.*)$/.match(line)
@saas786
saas786 / posts-page-warning.php
Created April 28, 2012 07:54 — forked from stephanieleary/posts-page-warning.php
Warn users not to edit the post container
<?php
// Add to functions.php or place in mu-plugins
// Admin Notice on Posts Page
add_action('admin_head-post.php', 'us2011_postspage_error_notice');
function us2011_postspage_error_notice() {
$postspage = get_option('page_for_posts');
if (!empty($postspage))
add_action('admin_notices', 'us2011_postspage_print_notices');
}
@saas786
saas786 / fetch-google-hourly-trends.pl
Created April 28, 2012 07:55 — forked from carlosmcevilly/fetch-google-hourly-trends.pl
fetch the google hourly trends atom feed