[]
= optional arguments{}
= flags that provide differnet functionality|
= or<>
= optional arguments for optional arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.ServerValidatedTextField = Ember.View.extend | |
tagName: 'input' | |
type: 'text' | |
### | |
This is handy if you want your server to validate an input field. | |
Your server is expected to return a boolean value | |
When that `validInput` attribute changes, we'll replace the layoutTemplate | |
with something that indicates valid or invalid. | |
You'll need three templates: `_loadingTemplate`, `_validTemplate`, `_invalidTemplate` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lines 16-17 and 21-22 don't make sense to me. | |
# If I stub a method on the user object, | |
# why is it not stubeed for the same object on the association? | |
describe "#approved" do | |
let(:user) { FactoryGirl.create(:user) } | |
subject(:bulletin) { FactoryGirl.build(:bulletin_post) } | |
it "is false if the user is not approved" do | |
# user.stub(:approved?) { true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is probably a fairly common use case | |
# but there must be a more elegant solution? | |
# shortened_url returns a bit.ly link or nil in development | |
class Post | |
def tweet_text | |
link_length = shortened_url ? shortened_url.length : "" | |
separator = "-" | |
available_chars = link_length - separator.length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "master" = "$(git rev-parse --abbrev-ref HEAD)" ] ; then | |
echo "\033[1;31mYou may not shove master\033[0m" | |
exit 1; | |
fi | |
exec git push --force origin HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am mehulkar on github. | |
* I am mehulkar (https://keybase.io/mehulkar) on keybase. | |
* I have a public key whose fingerprint is 0124 35B0 BA24 1473 594F 5712 8565 B49E 13F9 BF48 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by @mrmrs http://designbytyping.com/2014/10/17/cloning-repos/ | |
user="mehulkar" | |
# curl the pages directly instead of saving | |
# the urls to a txt file first | |
for page in {1..3}; do | |
curl "https://api.github.com/users/$user/repos?page=$page&per_page=100" >> repos.json | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Add this file to .git/hooks/pre-commit | |
# and make it executable. | |
# 1. greps the repo for "focus: true" | |
# 2. counts number of results | |
# 3. Strips the whitespace from the resulting number string | |
num=$(git grep "focus: true" | wc -l | xargs) |