Skip to content

Instantly share code, notes, and snippets.

@tswaters
tswaters / angular-resolve.md
Created August 6, 2015 06:33
defer controller initialization until after a $resolve function is resolved.

Not sure if this will at all come in handy, seems to me if the controller doesn't run it just won't show things. More of a starting point than anything else - without further ado, adding a $resolve function on a controller and have it resolve prior to controller initialization.

angular.module('resolve', [])
  .directive('resolveController', [
            '$controller', '$parse', '$injector', '$window',
    function($controller,   $parse,   $injector,   $window) {
      return {
        link: function(scope, elem, attrs) {
          var ctrlName = attrs.resolveController;
@tswaters
tswaters / ajax-helper.js
Last active August 29, 2015 14:23
ajax helper
function ajax (opts) {
if (this instanceof ajax) throw new Error("stop instantiating me!");
if (!opts) throw new Error("pass opts, dummy.")
if (!opts.url) throw new Error("pass url, dummy");
if (!opts.method) throw new Error("pass method, dummy");
var callbacks = {
success: [],
failure: [],
always: []
@tswaters
tswaters / git-subdirectory-tracking.md
Last active February 19, 2024 21:15
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@tswaters
tswaters / gist:d26036395341f5fdc17d
Last active August 29, 2015 14:04
Bind ctrl+shift+alt f1-12 to output various macros files
; bind ctrl+shift+alt f1-12 to output various macros files
Loop 12
{
Hotkey, ^!+f%A_Index%, OutputMacroFile
}
return
OutputMacroFile:
key := RegExReplace(A_thisHotkey, "[+!^]", "")
FileRead, Contents, %AppData%\macros\%key%.txt