Skip to content

Instantly share code, notes, and snippets.

View KevinTCoughlin's full-sized avatar

Kevin T. Coughlin KevinTCoughlin

View GitHub Profile
@KevinTCoughlin
KevinTCoughlin / get-watchers.js
Created March 3, 2016 01:21 — forked from kentcdodds/get-watchers.js
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
@KevinTCoughlin
KevinTCoughlin / angularjs_directive_attribute_explanation.md
Created February 10, 2016 22:24 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@KevinTCoughlin
KevinTCoughlin / gist:24a2d96ca1bdb984eeaa
Created January 8, 2016 16:20 — forked from andphe/gist:3232343
Export your links from Safari reading list
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
@KevinTCoughlin
KevinTCoughlin / springer-free-maths-books.md
Created December 28, 2015 23:55 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@KevinTCoughlin
KevinTCoughlin / PeekIterator.java
Last active November 19, 2015 01:18
Iterator implementation using composition that allows you to peek at the next value.
public class PeekIterator<T> {
@NonNull private final Iterator<T> iterator;
@Nullable private final T current;
public PeekIterator(Iterator<T> iter) {
this.iterator = iter;
}
public boolean hasNext() {
if (current != null) {
var input = "According to a research team at Cambridge University, it doesn't matter in what order the letters in a word are, \n"
+ "the only important thing is that the first and last letter be in the right place. \n"
+ "The rest can be a total mess and you can still read it without a problem.\n"
+ "This is because the human mind does not read every letter by itself, but the word as a whole. \n"
+ "Such a condition is appropriately called Typoglycemia.";
function typoglycemia(phrase) {
return phrase.split(' ').map(scramble).join(' ');
}
@KevinTCoughlin
KevinTCoughlin / CustomEditText.java
Last active November 6, 2015 20:29
Custom edit text layout espresso test question
/** Espresso type into custom edit text view test **/
Espresso.onView(ViewMatchers.withId(R.id.email)).perform(ViewActions.typeTextIntoFocusedView("[email protected]"));
/** CustomEditTextLayout.java **/
public class CustomEditTextLayout extends RelativeLayout implements OnClickListener {
private CustomEditText mEditText;
private TextView mErrorText;
public CustomEditTextLayout(final Context context) {
super(context);
var consonants = 'bcdfghjklmnpqrstvwxyz'.split('');
var vowels = 'aeiou'.split('');
var CONSONANT = 'c';
var VOWEL = 'v';
var input = ['cvcvcc', 'CcvV', 'cvcvcvcvcvcvcvcvcvcv'];
function generateWord(pattern) {
return pattern.split('').map(function(ch, idx, arr) {
var isUpperCase = ch === ch.toUpperCase();
var char = ch.toLowerCase();