Skip to content

Instantly share code, notes, and snippets.

@pockata
pockata / dump.php
Created September 26, 2013 12:09 — forked from eddmann/dump.php
function dump()
{
$args = func_get_args();
echo "\n<pre style=\"border:1px solid #ccc;padding:10px;margin:10px;font:14px courier;background:whitesmoke;display:block;border-radius:4px;\">\n";
$trace = debug_backtrace(false);
$offset = (@$trace[2]['function'] === 'dump_d') ? 2 : 0;
echo "<span style=\"color:red\">" . @$trace[1+$offset]['class'] . "</span>:" .
@pockata
pockata / functions.php
Created November 28, 2012 10:53
PHP: Full link from URI
function makeLink ($uri, $e = TRUE) {
static $url = NULL;
static $path = NULL;
static $qs = NULL;
if ( ! $url) {
$protocol = 'http';
if ( ! empty($_SERVER['HTTPS']) &&
$_SERVER['HTTPS'] !== 'off' ||
@pockata
pockata / def.php
Created November 4, 2012 12:39
PHP: bgDate
function bgDate ($date) {
$array1 = array(
"Monday","Tuesday","Wednesday","Thursday",
"Friday","Saturday","Sunday"
);
$array2 = array(
"Понеделник","Вторник","Сряда","Четвъртък",
"Петък","Събота","Неделя"
@pockata
pockata / page.php
Created June 27, 2012 18:17
WP: Sitemap page
<h3>Pages</h3>
<ul><?php wp_list_pages("title_li=" ); ?></ul>
<h3>Feeds</h3>
<ul>
<li><a title="Full content" href="feed:<?php bloginfo('rss2_url'); ?>">Main RSS</a></li>
<li><a title="Comment Feed" href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comment Feed</a></li>
</ul>
<h3>Categories</h3>
<ul><?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul>
<h3>All Blog Posts:</h3>
@pockata
pockata / functions.php
Created June 27, 2012 13:19
WP: Create better tags
function betterTags ($args=NULL, $echo=TRUE, $sizes=FALSE) {
if ($args == NULL) $args = 'format=array&echo=0&unit=px';
if ($sizes == FALSE) $sizes = range(10, 23);
$tags = wp_tag_cloud($args);
if (($c = count($tags)) > 0) {
for ($i=0; $i<$c; $i++) {
@pockata
pockata / functions.php
Created June 27, 2012 13:13
WP: Get post images
function get_post_images ($id) {
$images = get_children(array(
'post_parent' => $id,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
if ( ! $images) return FALSE;
@pockata
pockata / cpp.sublime-build
Created May 15, 2012 12:26
Sublime Text 2 C++ build tool (opens console window!)
{
"cmd": ["g++ -Wall ${file} -o ${file_base_name} && start ${file_base_name}"],
"working_dir": "${file_path}",
"selector": "source.c++",
"shell": true,
"encoding": "utf8"
}
@pockata
pockata / test.js
Created May 14, 2012 15:39
me going ape on JS :D
function addAppropriateData(selectID) {
// INCETION :D
var selects = {
'conf-opts-dd-height': {
'others': ['conf-opts-dd-length', 'conf-opts-dd-depth'],
'addData': function () {
}
},
// ----------------------------------------------------------
// 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) {}
@pockata
pockata / PHP Lambda function detection
Created March 3, 2011 15:00
PHP: Closure detection
function isClosure ($func) {
if ( ! is_object($func)) {
return FALSE;
}
return ($func instanceof Closure);
}