Skip to content

Instantly share code, notes, and snippets.

@xtbl
xtbl / Git Cheat sheet
Last active December 28, 2015 21:39
Git Cheat sheet
Setup
-----
How to undo (almost) anything with Git
https://github.com/blog/2019-how-to-undo-almost-anything-with-git
git clone <repo>
clone the repository specified by <repo>; this is similar to "checkout" in
some other version control systems such as Subversion and CVS
@xtbl
xtbl / deepDiffMapper
Created December 5, 2013 21:44
Find differences in JS objects
var deepDiffMapper = function() {
return {
VALUE_CREATED: 'created',
VALUE_UPDATED: 'updated',
VALUE_DELETED: 'deleted',
VALUE_UNCHANGED: 'unchanged',
map: function(obj1, obj2) {
if (this.isFunction(obj1) || this.isFunction(obj2)) {
throw 'Invalid argument. Function given, object expected.';
}
@xtbl
xtbl / Recursive Each.js
Last active January 1, 2016 09:49
get all the keys of an object
it('should get all the keys of an object', function() {
var selectedTile = { $$hashKey: 'testId', obj1:'test', obj2:5, obj3:{ test1:'test',test2:{a:1,b:2} } };
var selectedTile2 = { $$hashKey: 'testId', obj1:'test', obj2:5, obj3:{ test1:'test' } };
var keyList = [];
var recursiveEach = function(obj, customFunc) {
// using recursive each because _.each/_.keys only gets first level properties
for (var k in obj) {
if (typeof obj[k] == "object" && obj[k] !== null){
customFunc(k);
@xtbl
xtbl / How To Install MongoDB On Mac OS X.md
Created January 1, 2014 23:14
How To Install MongoDB On Mac OS X
@xtbl
xtbl / angularjs-interceptor-example.js
Last active January 3, 2016 11:39
AngularJS $interceptor example
// app.js
// http://djds4rce.wordpress.com/2013/08/13/understanding-angular-http-interceptors/
// http://blog.brunoscopelliti.com/http-response-interceptors
//any 404 error clean cookies and sends the user to login
var interceptor = ['$rootScope', '$q', '$location', '$cookieStore', function ($rootScope, $q, $location, $cookieStore) {
function success(response) {
@xtbl
xtbl / angularjs-testing-resource.js
Created January 21, 2014 20:22
AngularJS unit test using $resource
// verify you are not injecting 'ngMockE2E' for mock backend when working on unit tests
// and delete/comment mock backend stuff
// use httpBackend.flush() with $resource http://davidjs.com/2013/09/tricky-unit-testing-of-httpbackend/
// http://blogs.burnsidedigital.com/2013/09/and-httpbackend-mock-for-all-unit-e2e-testings/
describe( 'AppCtrl', function() {
describe( 'isCurrentUrl', function() {
var AppCtrl, $location, $scope;
var httpBackend;
<h3 class='post-title entry-title'>
<a href='http://www.nielskrijger.com/2013/08/rest-and-json-api-guidelines-and-best.html'>REST and JSON best practices</a>
</h3>
<div class='post-header'>
<div class='post-header-line-1'>
</div>
</div>
<div class='post-body entry-content'>
@xtbl
xtbl / bower.json
Created April 3, 2014 03:11
AngularJS Boilerplate updated dependencies April 2014
{
"name": "fsog",
"version": "0.0.1",
"devDependencies": {
"angular": "~1.2.15",
"angular-mocks": "~1.0.7",
"bootstrap": "~3.0.3",
"angular-bootstrap": "~0.10.0",
"angular-ui-router": "~0.0.1",
"angular-ui-utils": "~0.0.3",
@xtbl
xtbl / python_snippets.py
Created April 11, 2014 21:34
Python Snippets
# ExampleSnippets.txt
----------------------------------------------------------
*********************
CHAPTER 2:
*********************
--- HelloWorld ---