Skip to content

Instantly share code, notes, and snippets.

View bcherny's full-sized avatar

Boris Cherny bcherny

View GitHub Profile
@bcherny
bcherny / gist:8790541
Last active August 29, 2015 13:56
useful git combinators
# rebase from master, deferring to master
git rebase master -s recursive -X theirs
# see diff between 2 branches
git diff --name.status master..branch
# .. or alternatively,
git diff --stat --color master..branch
# merge into a branch from another one, squashing all commits into one
@bcherny
bcherny / angular-style.md
Last active August 29, 2015 13:56
Front End Style Guide - Angular

This is a work in progress - please modify and comment!

Coding Style

  • Any HTML templates should live in separate files in the "/template" directory, rather than as inline strings
    • PREREQUISITE: [ ] pre-compile and bundle templates with grunt to avoid proliferation of XHR requests
  • Use minimal plugin configs (eg. gridOptions for ng-grid): defer to defaults where possible. Same goes for other plugins - avoid lengthy configs where possible
  • Use extend, in order to add structure to property declarations:

// before

@bcherny
bcherny / ng-grid-gotchas.md
Last active August 29, 2015 13:56
ng-grid gotchas

1. To set minWidth or maxWidth, you need to set width to auto as well

good:

...
columnDefs: [
   { field: 'foo', width: 100 },
   { field: 'bar', width: 'auto', minWidth: 100 },  
 { field: 'baz', width: 'auto', maxWidth: 100 },
@bcherny
bcherny / gist:11231643
Last active August 29, 2015 14:00
Extract version from package.json
egrep '"version":' ./package.json | cut -d '"' -f4
/////////// option 1 //////////////////
// both turntable and the consumer can mutate this object, potentially breaking functionality:
$scope.params = {
limit: 100,
offset: 0,
searchString: '',
sortCriteria: 'country',
sortDirection: 'DESC'
};
function fetch (id) { ... }
var ids = [1,2,3,4];
$q
.all(ids.map(fetch))
.then( ... );

smart-table

<smart-table
   config="globalConfig"
   class="table table-striped"
   columns="usageStatsColumns"
   subheaders="subheaders"
   rows="usageStatsData"
>
/**
* usage:
*
* <html analytics-auto-tag> ... </html>
*
*/
angular
.module('webapp', ['angulartics', 'angulartics.adobe.analytics'])