Skip to content

Instantly share code, notes, and snippets.

@cdeocampo
cdeocampo / map_xml_property.php
Created December 6, 2012 09:56
PHP: Max XML Properties from SimpleXML Object
/**
* Convert XML Properties into key-value pair array where key=attribute name
* and value=value of attribute
* @param SimpleXML $xml
* @param Array $array property map
* e.g. $propertyMap = array(
"metadata" => array(
"item" => array(
"description" => array(true, 'page_description', 'stringParam'),
"keywords" => array(true, 'page_keywords'),

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync
@cdeocampo
cdeocampo / get_files.php
Created October 22, 2012 06:48
PHP: Get files to array
<?php
function getFiles($path, $extensions=null, &$files=null)
{
if(!is_dir($path)) return null;
$files = ($files==null)?array():$files;
$extensions = is_array($extensions) ? implode('|', $extensions) : $extensions;
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if(preg_match("/^.*\.(". $extensions .")$/i", $entry)) {
@cdeocampo
cdeocampo / gist:3878293
Created October 12, 2012 09:22 — forked from brianblakely/gist:581868
HTML: Useful <head> tags
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@cdeocampo
cdeocampo / annoying.js
Created October 12, 2012 09:22 — forked from Kilian/annoying.js
JS: How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@cdeocampo
cdeocampo / include-js.sublime-snippet
Created October 9, 2012 09:06
TwitterBootstrap: Add Script Snippet
<snippet>
<content><![CDATA[
<script src="${1:bootstrap/}js/bootstrap.${2:min.}js"></script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tbjs</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
<description>Bootstrap Add Script</description>
</snippet>
@cdeocampo
cdeocampo / include-css.sublime-snippet
Created October 9, 2012 08:56
TwitterBootstrap: Add Stylesheet Snippet
<snippet>
<content><![CDATA[
<link href="${1:bootstrap/}css/bootstrap.${2:min.}css" rel="stylesheet">
<link href="${1:bootstrap/}css/bootstrap-responsive.${2:min.}css" rel="stylesheet">
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tbcss</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
<description>Bootstrap Add Stylesheet</description>
@cdeocampo
cdeocampo / gist:3856302
Created October 9, 2012 02:52 — forked from shrwnsan/gist:2860805
Sublime Settings: Fetch Settings
{
"files":
{
"jquery" : "http://code.jquery.com/jquery.js",
"jquery.min" : "http://code.jquery.com/jquery.min.js",
"jquery-cookie" : "https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js",
"jquery-dotimeout" : "https://raw.github.com/cowboy/jquery-dotimeout/master/jquery.ba-dotimeout.min.js",
"jquery-extra-selectors" : "https://raw.github.com/keithclark/JQuery-Extended-Selectors/master/jquery-extra-selectors.js",
"jquery-flexslider" : "https://raw.github.com/mbmufffin/FlexSlider/master/jquery.flexslider-min.js",
"jquery-mediaelement" : "https://raw.github.com/johndyer/mediaelement/master/build/mediaelement-and-player.js",
@cdeocampo
cdeocampo / obj_to_assoc_array.php
Created October 8, 2012 03:15 — forked from grimicorn/obj_to_assoc_array.php
PHP: Object to Assoc. Array
function objectToArray($d) {
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object