Skip to content

Instantly share code, notes, and snippets.

View brendanjerwin's full-sized avatar

Brendan Erwin brendanjerwin

View GitHub Profile
@brendanjerwin
brendanjerwin / gist:5279096
Created March 31, 2013 01:26
How are my Obj-C idioms?
//
// main.m
// Juice
//
// Created by Brendan Erwin on 3/26/13.
// Copyright (c) 2013 Brendan Erwin. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ObjectiveSugar.h"
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
function clean_up {
git stash pop -q
private static readonly Dictionary<HandlerQueue, Guid> QueueToResourceManagerId = new Dictionary<HandlerQueue, Guid> {
{ HandlerQueue.Admin, Guid.Parse("b7128b8d-a4b6-4ea0-b6c5-03f0e58b6dfa")},
{ HandlerQueue.Artifact, Guid.Parse("dc1d7cd9-ee60-4bd0-aebe-496e3bde22a7")},
{ HandlerQueue.Attestation, Guid.Parse("e66e0847-dc93-4e0b-8c9b-63cb2f75a0b4")},
{ HandlerQueue.AuthenticatedPrincipals, Guid.Parse("e7f026ed-538e-41ea-8b3e-693cd14408d8")},
{ HandlerQueue.Disclosure, Guid.Parse("319aa5ea-1563-465b-a6e6-2b7b7cd20ed5")},
{ HandlerQueue.Email, Guid.Parse("4718b4cf-3741-4f48-a002-8dd4bffc16ad")},
{ HandlerQueue.General, Guid.Parse("a4901f2d-d009-42d4-8055-5a4899138680")},
{ HandlerQueue.LinkLibrary, Guid.Parse("a5704cef-c4f1-48b7-a579-cf200f5f6974")},
{ HandlerQueue.Policy, Guid.Parse("edaa0c2a-7a41-454e-9056-1409567ff577")},
is_end_of_tag = (char)-> char is '>'
is_start_of_tag = (char)-> char is '<'
is_whitespace = (char)-> /\s/.test char
is_tag = (token)-> /^\s*<[^>]+>\s*$/.test token
isnt_tag = (token)-> not is_tag token
class Match
constructor: (@start_in_before, @start_in_after, @length)->
@end_in_before = (@start_in_before + @length) - 1
@end_in_after = (@start_in_after + @length) - 1
{
"payload":
{
"suite": {
"acl": ["Suite.People.Manage", "Suite.Permissions.Manage"]
},
"policyManagement": {
"isAvailableToTenant": true,
"minimumNumberOfPolicyApprovers": 9,
"acl": ["PolicyManagement.Policies.Manage", "PolicyManagement.Permissions.Manage", "PolicyManagement.Reporting.Manage"]
options?.el?.data? 'gleeView',fakeController
return fakeController
initializer.render = (params...)-> initializer(params...).render()
initializer.extend = (params...)-> _.extend(initializer, params...)
initializermakeSpyReset = initializer.reset
initializer.reset = ->
renderSubViews: function(options){
var el = options.el;
var items = options.items;
if(!el){throw Error('renderSubViews must be provided an el option to render into.');}
if(!items){throw Error('renderSubViews must be provided and items option containing the models to render.');}
if(!this.subView){throw Error('cannot call renderSubView without the view implementing the subView key.'); }
var i,j;
this._glee_items_el = el;
for(i=0,j=items.length;i<j;i++){
this.addSubView(items[i], options);
define ['query/api', 'lib/underscore', 'mixins/policy_product_access_authority_mixin'], (query, _, policyProductAccessAuthorityMixin)->
products = query['Products']()
products.done (result)->
_(products).extend result
return products
map <leader>d :echo system("screen -S specs -p 0 -X stuff 'shopt -s nullglob\n export PS1=\n cd " . getcwd() . "\nclear\n mocha debug -R spec " . expand("%:p:h") . "/*.spec.js " . expand("%:p:h") . "/*.spec*/**/*.spec.js\n'")<CR>
map <leader>t :echo system("screen -S specs -p 0 -X stuff 'shopt -s nullglob\n export PS1=\n cd " . getcwd() . "\nclear\n mocha -R spec " . expand("%:p:h") . "/*.spec.js " . expand("%:p:h") . "/*.spec*/**/*.spec.js\n'")<CR>
map <leader>T :echo system("screen -S spec_suite -p 0 -X stuff 'export PS1=\n cd " . getcwd() . "\nclear\n mocha -R progress " . getcwd() . "/**/*.spec.js\n'")<CR>
function! Refactor()
call inputsave()
let @z=input("What do you want to rename '" . @z . "' to? ")
call inputrestore()
endfunction
" Locally (local to block) rename a variable
autocmd FileType coffee nmap <buffer> <Leader>rr "zyiw:call Refactor()<cr>mx:silent! norm gd<cr>Vii%:s/<C-R>//<c-r>z/g<cr>`x
autocmd FileType javascript nmap <buffer> <Leader>rr "zyiw:call Refactor()<cr>mx:silent! norm gd<cr>[{V%:s/<C-R>//<c-r>z/g<cr>`x