Skip to content

Instantly share code, notes, and snippets.

@schleim
schleim / content.html
Last active November 19, 2015 09:55
Angular directive with expression in attribute
<section class="accordion" accordion accordion-on-open="showImage=true" >
<dl>
<dt>
<a href="" class="">Link</a>
</dt>
<dd class="cf ">
Content
<img ng-if="showImage" src="">
</dd>
</dl>
@schleim
schleim / gist:fe8b8384bcf05a0fba70
Last active April 25, 2016 11:05
URL Params to Object
var queryObject = function () {
var queryString = {};
var query = decodeURIComponent(window.location.search).substring(1);
var items = query.split('&');
if(items.length == 1 && items[0] === '') return queryString;
for (var i=0;i<items.length;i++) {
var pair = items[i].split('=');
if (typeof queryString[pair[0]] === 'undefined') {
queryString[pair[0]] = pair[1];
} else if (typeof queryString[pair[0]] === 'string') {

Keybase proof

I hereby claim:

  • I am schleim on github.
  • I am streich (https://keybase.io/streich) on keybase.
  • I have a public key whose fingerprint is 201D 5CC9 8A1A A43B 5541 89D3 005F FFA1 239D C360

To claim this, I am signing this object:

@schleim
schleim / gist:8b5852d3a541cb3b0df3
Created April 14, 2015 21:48
Add missing HTTP to url
function addHttp(url) {
if (!url.match(/^(f|ht)tps?:\/\//)) {
url = "http://" + url;
}
return url;
}
@schleim
schleim / gist:7a96b4965dff5e6f0a60
Created February 27, 2015 11:44
Gulp: Move folders and contents to a different location
gulp.task('move', function(){
return gulp.src(['modules/core/client/css/**/*.*'])
.pipe(gulp.dest('public/dist'));
});
@schleim
schleim / gist:ad354b02b02f9fc50951
Last active August 29, 2015 14:16
map value to range
// re-maps a value from one range to another.
function map(value, fromMin, fromMax, toMin, toMax) {
return toMin + (toMax - toMin) * ((value - fromMin) / (fromMax - fromMin));
}

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
function goToURL(url)
{
var win = window.open(url, '_blank');
win.focus();
}
@schleim
schleim / .htaccess
Last active August 29, 2015 14:12 — forked from ScottPhillips/.htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@schleim
schleim / gist:7fc147a66467112cdf6e
Created November 10, 2014 16:21
Loop through terms of a certain taxonomy (Wordpress)
<?php
$taxonomy = 'taxonomy_name';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$args = array(