Skip to content

Instantly share code, notes, and snippets.


Jamis Charles jamischarles

View GitHub Profile
jamischarles / YUI_new_module.js
Created Feb 8, 2011
This is a great way to define modules for the YUI loader and ensuring the dependencies get pulled in
View YUI_new_module.js
YUI.add('breeze-nav', function(Y) {
bb.session.Nav = function() {
// expose an API
// this in here will execute when it's pulled in through YUI().use()
jamischarles / YIU_3_getNode.js
Created Feb 14, 2011
YUI: pass in raw node OR id in YUI 3
View YIU_3_getNode.js
var getNode = function(el) {
//fetch the node by selector, or wrap it in a new YUI Node instance
return'#' + el) || new Y.Node(el);
jamischarles / inject_script_node.js
Created Jun 19, 2011
Non blockin JS script node insertion with a callback
View inject_script_node.js
var headID = document.getElementsByTagName("head")[0];
//create new script
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
//add callback
newScript.onload = function(){ alert("loaded");};
newScript.src = '';
jamischarles / anonymous_function.js
Created Jun 19, 2011
Self invoking anonymous function
View anonymous_function.js
//of this will execute privately without exposing the variables to the global object and without polluting the global namespace.
function test(){
jamischarles / sanitize_json.js
Created Jun 25, 2011
JavaScript: Sanitize JSON string before saving, so it can be read again. (Escapes newlines etc)
View sanitize_json.js
function sanitizeJSON(unsanitized){
return unsanitized.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\f/g, "\\f").replace(/"/g,"\\\"").replace(/'/g,"\\\'").replace(/\&/g, "\\&");
jamischarles / functions.php
Created Apr 25, 2012
Display links to WordPress blog posts on non-WP pages using the WordPress API.
View functions.php
//add this code at the end of "functions.php" (Theme Functions). This can be accessed through the WP admin menu under Appearance -> Editor -> Theme Functions
//this is the logic to get the posts you want
function displayHomePosts(){
//default values obj from post.php.
//pass these in as args that you really want
$defaults = array(
'numberposts' => 5, 'offset' => 0,
'category' => 0, 'orderby' => 'post_date',
View nodejs_express_file-structure.markdown

consider making a node-guides site like rails guides?

Approach 1:

TJ HollowayChuck (creator of Express)

"personally I find large rails-style structure difficult to work with for large applications (great for small ones however). A more modular approach like Drupal is a big win as far as management goes but it can complicate some things (layout templates) so you kind of need

jamischarles / sublime_shortcuts.markdown
Created Oct 10, 2012
Most useful Sublime Shortcuts
View sublime_shortcuts.markdown

Usefulness is indicated by amount of stars.

All are currently Mac only

Expand selection to tag **

Shift + Cmd + A

Wrap selection with tag **

Ctrl + Shift + W

View clearfix.css
/* (taken from bootstrap github conversation) */
/* Utility classes */
/* Clearfix */
/* Clearfix for modern browsers */
.cf:after {
content: "";
display: table;
jamischarles / css_center.css
Created Feb 4, 2015
CSS: Center horizontally and vertically
View css_center.css
/* Supported IE8+ */
.el {
display: table-row;
width: 100%;