Skip to content

Instantly share code, notes, and snippets.

Jamis Charles jamischarles

  • PayPal
  • near Boulder, CO
Block or report user

Report or block jamischarles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jamischarles
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',
@jamischarles
jamischarles / .npm_install_autocomplete_bash
Last active Jul 13, 2016
npm install autocompletion for bash. Provides content of `~/.npm` as autocomplete options for `npm install` https://medium.com/@jamischarles/adding-autocomplete-to-npm-install-5efd3c424067#.8w0jzkh3w
View .npm_install_autocomplete_bash
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS
# BASH standalone npm install autocomplete. Add this to ~/.bashrc file.
_npm_install_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
@jamischarles
jamischarles / npm_install_autocomplete_zsh
Last active Jul 4, 2016
npm install autocompletion for bash & zsh. Provides content of `~/.npm` as autocomplete options for `npm install` https://medium.com/@jamischarles/adding-autocomplete-to-npm-install-5efd3c424067#.8w0jzkh3w
View npm_install_autocomplete_zsh
#!/usr/bin/env zsh #adding this to force silly gist highlighting. REMOVE THIS
# ZSH standalone npm install autocompletion. Add this to ~/.zshrc file.
_npm_install_completion() {
local si=$IFS
# if 'install' or 'i ' is one of the subcommands, then...
if [[ ${words} =~ 'install' ]] || [[ ${words} =~ 'i ' ]]; then
# add the result of `ls ~/.npm` (npm cache) as completion options
@jamischarles
jamischarles / node_invalid_ssl.js
Created Jun 22, 2016
Node https request to server with invalid SSL certs
View node_invalid_ssl.js
// use this when you can curl an https server, but node request() will return 'econnreset: socket hang up'
var options = {
url: 'https://some/site',
method: 'POST',
// these 3 lines matter
strictSSL: false,
secureProtocol: 'TLSv1_method',
rejectUnhauthorized: false
}
@jamischarles
jamischarles / .npm_install_autocomplete
Last active May 27, 2016
Make these changes to augment your local npm autocompletion to include autocomplete for `npm install`
View .npm_install_autocomplete
#!/usr/bin/env bash #adding this to force silly gist highlighting
# If you are already using npm autocompletion via (https://docs.npmjs.com/cli/completion), I assume that you have some code in
# your .bashrc/.zshrc file. Follow the instruction below to avoid clobbering the npm autocomplete script.
#####################
#### FOR BASH change THIS (in your .bashrc file)
#####################
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
@jamischarles
jamischarles / es6_functions.js
Created Oct 13, 2015
es6 functions explained...
View es6_functions.js
// method shorthand. ES6 version.
{
initialize() {},
doSomething() {}
}
// replaces (ES5)
{
View clearfix.css
/* (taken from bootstrap github conversation) */
/* Utility classes */
/* Clearfix */
/* Clearfix for modern browsers */
.cf:before,
.cf:after {
content: "";
display: table;
@jamischarles
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 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
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 = 'http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js';
You can’t perform that action at this time.