Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
writing computer programs

Mr Rogers bunnymatic

💭
writing computer programs
View GitHub Profile
@bunnymatic
bunnymatic / a.md
Last active Aug 29, 2015 — forked from shamus/a.md
View a.md

Communication between collaborating Directives

Directives man! While the they're literally the entry point into angular development (you can't get going without ng-app), many people starting out with Angular are hesistant to write their own because of the complexity associated with them. But once that initial hurdle is crossed their value as reusable components becomes indispensible.

Occasionally a complicated component will come along, one

@bunnymatic
bunnymatic / index.html
Created Nov 21, 2014
html with jquery and lodash
View index.html
<html>
<head>
</head>
<body>
</body>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</html>
@bunnymatic
bunnymatic / Gemfile
Last active Aug 29, 2015
git bumper playtime
View Gemfile
source "https://rubygems.org"
gem 'git'
@bunnymatic
bunnymatic / gist:a78deb0e3274af571916
Created Jul 9, 2014
who done it - git blame statistics
View gist:a78deb0e3274af571916
Hop into a shell and to the root directory of your project and run
git ls-tree --name-only -z -r HEAD -- $1 | xargs -0 -n1 git blame --line-porcelain | grep "^author "|sort|uniq -c|sort -nr
Then wait a bit. You get a nice sorted list of lines of code and author name.
Add it to your bash profile like this
whodunit() {
git ls-tree --name-only -z -r HEAD -- $1 | xargs -0 -n1 git blame --line-porcelain | grep "^author "|sort|uniq -c|sort -nr
}
@bunnymatic
bunnymatic / clock.js
Last active Aug 29, 2015
cordova clock
View clock.js
SummitClock = {
twoDigits: function(v) {
return ("0" + v).slice(-2);
},
updateTime: function() {
var c = document.getElementById('clock');
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var secs = now.getSeconds();
@bunnymatic
bunnymatic / myproject_s3.rb
Created Feb 28, 2014
Build signed read url for s3/aws access outside of the aws-sdk#url_for which doesn't like filenames with w/spaces
View myproject_s3.rb
module MyProject
class S3
def config
Rails.application.config.s3_config
end
def url_for_read(path, opts)
expire_date = (Time.zone.now + opts[:expires]).to_i
request_string = "GET\n\n\n#{expire_date}\n/#{config[:bucket]}/#{path}"
hmac = OpenSSL::HMAC.digest(digest, config[:secret_access_key], request_string)
@bunnymatic
bunnymatic / container.html
Last active Aug 29, 2015
js flash plugin
View container.html
<div id="fixture">
<div class="container">
</div>
<div class="container">
</div>
</div>
View completion-exercism.bash
__from_exercism_config() {
COMPREPLY=()
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W 'current demo fetch login logout peek restore submit unsubmit whoami help' -- $cur))
}
complete -F __from_exercism_config -o default exercism
@bunnymatic
bunnymatic / hot_stuff-1.rb
Last active Jan 2, 2016
active_model_conversion blog post assets
View hot_stuff-1.rb
# the hot stuff wrapper/presenter
class HotStuff
def items
@items ||= Stuff.hot.limit(5)
end
end