Skip to content

Instantly share code, notes, and snippets.

View kdimatteo's full-sized avatar

Keith DiMatteo kdimatteo

View GitHub Profile
@kdimatteo
kdimatteo / gist:583927025c9197ace2fe
Created August 13, 2014 19:05
whats my ip address
curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
@kdimatteo
kdimatteo / gist:eeed7a8788c1544e72aa
Created October 22, 2014 17:10
Disallow force pushing to master
#!/bin/bash
# this file is ./git/hooks/pre-push
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo "y u do this? (You can not push to master)"
exit 1;
@kdimatteo
kdimatteo / gist:2bc0aa0906c326770b0d
Last active August 29, 2015 14:10
ember-cli http-mock proxy
// file: /server/proxies/products.js
// instead of a mock, i always want to hit the API for this endpoint...
module.exports = function(app) {
var url = require('url');
var proxy = require('proxy-middleware');
app.post("/api/products/*", proxy(url.parse('http://foo.bar.com/api/products')));
};
@kdimatteo
kdimatteo / gist:fc2cb3d7726de60ff8f3
Created January 23, 2015 21:41
Convert {{#each foo in foos}} to {{#each foos as |foo|}} with this one weird Vim/sed trick:
:s/#each\s\v\zs(<\w*>)\sin\s(<(\w|.)*)>/\2 as |\1|/
@kdimatteo
kdimatteo / gist:0909cd415459869cce03
Last active August 29, 2015 14:27
RHEL CI Provision
yum install -y jenkins
yum install -y git
yum install -y nodejs
yum install -y npm
echo "Fix Node JS naming issue with a symlink"
ln -s /usr/bin/nodejs /usr/bin/node
#download jenkins CLI
wget http://localhost:6060/jnlpJars/jenkins-cli.jar
@kdimatteo
kdimatteo / gist:7db7d06e9b46dfbfa110
Created September 17, 2015 18:30
T-Account example
<table border="0" cellpadding="0" cellspacing="0" class="ez-t-account">
<thead>
<th colspan="2">A T-Account</th>
</thead>
<tbody>
<tr>
<td>$300<br>$1,200</td>
<td>$1,500</td>
</tr>
</tbody>
@kdimatteo
kdimatteo / gist:bf17920d95a6452f33b8
Created November 9, 2015 19:24
Count Angular Watchers
// taken from http://ng.malsup.com/#!/counting-watchers
(function countAngularWatchers(angular) {
var i, data, scope,
count = 0,
all = document.all,
len = all.length,
test = {};
var mostWatchers = 0;
function numToWords (num) {
var a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
var b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety'];
if ((num = num.toString()).length > 9) {
return 'num overflow';
}
var n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
if (!n) return;
var str = '';
@kdimatteo
kdimatteo / components.hello-component.js
Created August 23, 2016 14:02 — forked from danlourenco/components.hello-component.js
component interpolation within handlebars template
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['ember-component']
});
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}