Skip to content

Instantly share code, notes, and snippets.

View benhowdle89's full-sized avatar

Ben Howdle benhowdle89

View GitHub Profile
NSInteger count = [timelineData count];
for (NSInteger index = (count - 1); index >= 0; index--) {
NSMutableDictionary *tweet = timelineData[index];
if (tweet[@"retweeted_status"]) {
[timelineData removeObjectAtIndex:index];
} else {
NSMutableDictionary *userObject = [tweet[@"user"] mutableCopy];
int fav_count = tweet[@"favorite_count"];
int rt_count = tweet[@"retweet_count"];
int follower_count = userObject[@"followers_count"];
@benhowdle89
benhowdle89 / gist:9533185
Created March 13, 2014 17:41
Gulp + Watchify + Browserify + Handlebars + LiveReload
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var livereload = require('gulp-livereload');
var hbsfy = require("hbsfy").configure({
extensions: ["html"]
});
gulp.task('watch', function() {
@benhowdle89
benhowdle89 / 0_reuse_code.js
Created February 1, 2014 20:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@benhowdle89
benhowdle89 / gist:7584827
Last active February 7, 2024 11:30
A todo app you can run from the browser's address bar. No persistence (boo localstorage security risk). Made by @benhowdle.
data:text/html,<div class="wrap"> <h1>Todo<span>, no fuss lists</span></h1> <input placeholder="Add a todo" type="text" id="item" /> <button id="go">Save</button> <span class="help">* tap to delete</span> <ul id="tudu_list"> </ul> </div><script type="text/javascript">var tudu_list = document.getElementById('tudu_list'); var item = document.getElementById('item'); var new_li; var new_obj = {}; function prependElement(parentID,child) { parent=parentID; parent.insertBefore(child,parent.childNodes[0]); } function remove(element){ element.parentNode.removeChild(element); } function deleteItem(){ var answer = confirm('Sure you want to remove this?'); if(answer){ var deleteId = this.getAttribute('rel'); remove(this); } } function addItem(){ if(item.value !== ''){ new_li = document.createElement('li'); new_li.innerHTML = item.value; prependElement(tudu_list, new_li); new_li.onclick = deleteItem; item.value = ''; } } function callAdd(e){ if(event.keyCode == 13){ addItem(); } } item.onkeyup = function(e){ callAdd(e) };
@benhowdle89
benhowdle89 / gist:7097460
Created October 22, 2013 09:04
Makes the keyboard disappear on mobiles with JS
var activeElement = document.activeElement;
if(activeElement){
activeElement.blur();
}
@benhowdle89
benhowdle89 / gist:7083705
Created October 21, 2013 13:15
How http://healthcare.gov checks if the device is mobile...
// checks screen size
var isMobile = {
any: function() {
return($(window).width()<=599);
// nexus7 width is 600 (window.innerWidth)
// this will not run any reformatting for the phone layout on nexus
}
};
@benhowdle89
benhowdle89 / gist:6990074
Created October 15, 2013 11:17
Forcing browser reflows
var forceReflow = function(el) {
el = el || document.body;
el.style.position = 'static';
setTimeout(function() {
el.style.position = 'relative';
}, 0);
}
@benhowdle89
benhowdle89 / gist:6975823
Created October 14, 2013 13:43
Displays all images on a page on sites like http://bukk.it for example. Run in console or make a Bookmarklet.
var a=document.links;i=0;for(l=a.length;i<l;i++){var b=new Image;b.src=a[i].href;a[i].insertBefore(b)};
<ul class={{#oneOrMany posts}}{{/oneOrMany}}>
{{#each posts}}
<li>{{content}}</li>
{{/each}}
</ul>
@benhowdle89
benhowdle89 / gist:6266821
Last active December 21, 2015 06:49
Nested GH-pages
So, I create a gh-pages on my main account: benhowdle89.github.com repo and
point my domain at it http://benhowdle.im. I then create gh-pages in one of
my repos: so, http://benhowdle.im/svgeezy will point at my repo
benhowdle.github.com/svgeezy. That's all good.
HOWEVER.
What would happen if I create a folder in my jekyll site at the root,
ie. in benhowdle.github.com called "svgeezy"?