Skip to content

Instantly share code, notes, and snippets.

View paulmsmith's full-sized avatar

Paul Smith paulmsmith

View GitHub Profile
@paulmsmith
paulmsmith / demo of call pwer
Created November 12, 2016 15:44
call explanation nunjucks/jinja
{# The field macro which accepts the configuration object and uses it #}
{% macro field(config) %}
<div class="field-row field-row--{{ config.type | d('text') }}{{ ' field-row--' + config.size if config.size }}">
{# the caller is then invoked and the config is passed back #}
{% if caller %}{{ caller(config) }}{% else %}<p>Default HTML here</p>{% endif %}
</div>
{% endmacro %}
{# calling the 'field' macro and passing in a configuration object (could be a JSON schema) #}
@paulmsmith
paulmsmith / untitled
Created October 5, 2016 20:49
massively over-engineered button macro
{# global anchor ui element #}
{% macro abstractButton(options) %}
{% if not(ctx.ua.isMobile) and options.link.metaData.visibility != "mobile" or ctx.ua.isMobile and options.link.metaData.visibility != "desktop" %}
{%- set elm = options.elm | d('a') %}
<{{ elm }}
{{ (options.link.mobileAlt if ctx.ua.isMobile) | d(options.link.url) | d('#') | attr('href') if elm == 'a' }}
{{ options.baseClass | d("link") | componentClasses(options.metaData) | attr('class') }}
{{ options.link.properties.id | attr('id') }}
{{ options.metaData.data | pairs | attrs('data-') | join(' ') if options.metaData.data }}
{{ options.link.title | attr('title') }}
// ############################################################################
// core low level utility/helper functions
// ############################################################################
/// @function map-value
/// Returns a value from a nested map.
///
/// @access public
/// @param {Map | Number | String} $map-value - A map or value which is checked recursively.
/// @param {List} $map-value - The list of keys in sequential order.
@paulmsmith
paulmsmith / unrar.sh
Created June 18, 2016 15:06 — forked from zyuzuguldu/unrar.sh
unrar
for <var> in <list>
do
command $<var>;
done
# to unrar all rar files
for f in *.rar;do unrar e "$f";rm "$f";done
for f in *.001;do 7z e "$f";done
@paulmsmith
paulmsmith / untitled
Created June 1, 2016 10:28
regular expression to find element with particluar class string
<span\s(?:class="section-progress")>(.*)<\/span\>
@paulmsmith
paulmsmith / untitled
Created May 10, 2016 11:08
example jon
{% macro item(args) %}
<li>blah</li>
{% endmacro %}
{% macro nav(args) %}
<ul>
{{ item('foo')}}
{{ item('bar')}}
</ul>
{% endmacro %}
@paulmsmith
paulmsmith / server.js
Created March 8, 2016 20:37
meh postData
app.use(function (req, res, next) {
_.merge(res.locals,{
serviceName: config.cookieText,
cookieText: config.serviceName,
path: req.params[0],
postData: (req.body ? req.body : false)
});
next();
});
@paulmsmith
paulmsmith / copyright
Last active March 2, 2016 09:00
copyright character
@paulmsmith
paulmsmith / keymap.cson
Created January 28, 2016 12:29
emmet + nunjucks in atom with snippets
'atom-text-editor[data-grammar="text html nunjucks"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
'atom-text-editor[data-grammar="source nunjucks"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
#https://github.com/atom/autocomplete-plus/issues/86#issuecomment-82661027
'atom-text-editor.autocomplete-active:not([mini])':
'tab': 'autocomplete-plus:confirm'
@paulmsmith
paulmsmith / keymap.cson
Created January 26, 2016 14:57
Add this to keymap.cson file to ensure emmet & nunjucks grammar play nice together in atom
'atom-text-editor[data-grammar="text html nunjucks"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'