Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Trindall Trindaz

View GitHub Profile
View Delete branches older than one month locally and on remote.sh
for k in $(git branch | sed /\*/d); do
if [ -n "$(git log -1 --before='1 month ago' -s $k)" ]; then
git branch -D $k
git push origin --delete $k
fi
done
@Trindaz
Trindaz / fyi-def.txt
Created Dec 3, 2014
FYI definition according to Dave Trindall
View fyi-def.txt
FYI - For Your Information.
I just want to add a useful comment to your pull request.
There's no need to make changes right now.
This comment is not blocking a merge of this PR from happening.
@Trindaz
Trindaz / hash.js
Created Nov 18, 2014
A deterministic, circular reference safe hash function for javascript objects
View hash.js
function hash(obj) {
var cache = [];
function sanitize(obj) {
if (obj === null) { return obj; }
if (['undefined', 'boolean', 'number', 'string', 'function'].indexOf(typeof(obj)) >= 0) { return obj; }
if (typeof(obj)==='object') {
var keys = Object.keys(obj).sort(),
values = [];
@Trindaz
Trindaz / ancestry-of-attributes.js
Last active Aug 29, 2015
DOM Ancestry of non-standard HTML4 attributes
View ancestry-of-attributes.js
var ancestryOfAttributes = function(targetNode){
result = [];
while(targetNode.parentNode){
var attrs = [];
for(var i=0; i<targetNode.attributes.length; i++){ attrs.push(targetNode.attributes[i].nodeName); }
result.unshift(attrs.join(","));
targetNode = targetNode.parentNode
}
return JSON.stringify(result, undefined, 4);
};
View gist:a8c58d2e911ace1ca7c8
<html>
<head>
<style>
.imageList img {
transition: opacity 2s ease;
}
.imageList img.inactive {
opacity: 0;
View code_eval_score.py
def get_submission_score(score, memory_taken, time_taken, category):
"""
@param score: the score which is received by test-cases
@param memory_taken: memory taken by submission
@param time_taken: time taken by submission
@param category: Easy(1)/Moderate(2)/Hard(3)
"""
total_max = {
1: 35, # max 35 points for Easy challenge
@Trindaz
Trindaz / gist:11139437
Created Apr 21, 2014
client/views/posts/post_item.html from Discover Meteor
View gist:11139437
<template name="postItem">
<div class="post">
<div class="post-content">
<h3><a href="{{url}}">{{title}}</a><span>{{domain}}</span></h3>
</div>
<a href="{{postPagePath this}}" class="discuss btn">Discuss</a>
</div>
</template>
@Trindaz
Trindaz / gist:11139409
Created Apr 21, 2014
client/helpers/router.js from Discover Meteor
View gist:11139409
Meteor.Router.add({
'/': 'postsList',
'/posts/:_id': {
to: 'postPage',
and: function(id) {
Session.set('currentPostId', id);
}
}
});
View .vimrc
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
@Trindaz
Trindaz / gist:5351634
Created Apr 10, 2013
How do I make these two divs line up in the center?
View gist:5351634
<html>
<head>
<title>Side By Side Div Example</title>
<style>
div.left-column {
background-color: yellow;
display: inline;
}
You can’t perform that action at this time.