Skip to content

Instantly share code, notes, and snippets.

@jamestalmage
jamestalmage / AngularJS.xml
Last active August 1, 2017 10:39
Intellij Live Templates I have found usefull
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="AngularJS">
<template name="ngdcf" value="function compile(tElement, tAttrs, transclude) { &#10; $END$&#10; return function (scope, element, attrs) { &#10; }&#10;}" description="A compile function" toReformat="false" toShortenFQNames="true">
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
<option name="JSP" value="false" />
<option name="CSS_PROPERTY_VALUE" value="false" />
@jamestalmage
jamestalmage / input.js
Last active August 29, 2015 14:16
Annotation Idea
describe('myModule', function(){
beforeEach(module('myModule'));
/* @ngInject */
var a, b;
it('does things', function() {
// ....
});
});
@jamestalmage
jamestalmage / NPM INIT DEFAULTS.md
Last active November 25, 2018 13:55
Set up npm.init defaults

copied from iamsim

$ npm config set init.author.name "James Talmage"
$ npm config set init.author.email james@talmage.io
$ npm config set init.author.url http://iamsim.me/
$ npm config set init.license MIT
@jamestalmage
jamestalmage / generate-password.sh
Created April 29, 2015 18:19
Command Line Random Password Generator
#!/usr/bin/env bash
GEN_PASS=$(dd if=/dev/urandom bs=1 count=9 2>/dev/null | base64 | rev | cut -b 2- | rev)
echo $GEN_PASS
echo $GEN_PASS | pbcopy
GEN_PASS=0
/pattern/flags
new Regexp(pattern[, flags])

flags: g global, i ignore case, m multiline

regex.test(string) or string.search(regex) - returns true or false

regex.exec(string) - null or an array. 0 index is matched string, 1+ is captures. Maintains state for continuation searches /g flag is set.

@jamestalmage
jamestalmage / Docker - WORKING
Last active August 29, 2015 14:24
Dump of global dependency tree for generator-nm issue
root@42474955d2f4:~/temp# npm ls -g
/usr/local/lib
├─┬ generator-nm@1.4.0
│ ├─┬ humanize-url@1.0.1
│ │ └── strip-url-auth@1.0.1
│ ├─┬ normalize-url@1.3.0
│ │ ├── object-assign@3.0.0
│ │ ├── prepend-http@1.0.1
│ │ ├── query-string@2.3.0
│ │ └─┬ sort-keys@1.1.0
@jamestalmage
jamestalmage / forward.md
Last active April 9, 2024 17:21
Using Firebase to Authenticate to Google Drive

Note: There is a lot of information here, but if I have provided a link, it is probably something you should click on and read. OAuth is a complex enough subject on it's own, and hacking these two services together only adds to it.

Even so, I have found Firebase's API to be simpler than almost any other OAuth solution I have explored. When all is said and done, the important bits of code related to authentication is actually less than 10 lines. If you have ever tried to implement your own OAuth flow before, you know how amazing that is.

In the end, it may be worth using Firebase for authentication, even if that's the ONLY thing you use it for.

@jamestalmage
jamestalmage / bash
Created September 22, 2015 04:14
NPM - Transfer ownership of all your packages to somebody else
npm search james.talmage | awk '{system("npm owner add jamestalmage "$1)}'
@jamestalmage
jamestalmage / output.md
Last active May 11, 2018 15:58
Test what features firebase-server supports

Got Value: { DC: 'District of Columbia', DE: 'Delaware', FL: 'Florida', FM: 'Federated States of Micronesia', GA: 'Georgia', GU: 'Guam', HI: 'Hawaii', ID: 'Idaho', IL: 'Illinois', IN: 'Indiana'

@jamestalmage
jamestalmage / ErrorInFbDemo.md
Last active October 14, 2015 22:31
Error in Firebase Demo

https://www.firebase.com/blog/2015-10-07-how-to-keep-your-data-consistent.html

function fanoutPost({ uid, followersSnaphot, post, postId }) {
  // Turn the hash of followers to an array of each id as the string
  var followers = Object.keys(followersSnaphot.val());
  var fanoutObj = {};
  // write to each follower's timeline
  // Correction: I think it needs something like this:
 followers.forEach((key) =&gt; fanoutObj['/timeline/' + key + '/' + postId] = post);