Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

Alpha AlphaGit

View GitHub Profile
@AlphaGit
AlphaGit / Gruntfile.js
Created August 8, 2015 05:30
Configuring Protractor to run
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
connect: {
server: {
options: {
hostname: 'localhost',
port: 9001,
base: '.'
@AlphaGit
AlphaGit / 01 - Theme Testing Process.markdown
Created February 6, 2015 12:11
Theme testing process (from Wordpress Codex)

Theme Testing Process

from Theme Development (Wordpress Codex)

  • Fix PHP and WordPress errors. Add the following debug setting to your wp-config.php file to see deprecated function calls and other WordPress-related errors: define('WP_DEBUG', true);. See Deprecated Functions Hook for more information.
  • Check template files against Template File Checklist.
  • Do a run-through using the Theme Unit Test.
  • Validate HTML and CSS. See Validating a Website.
  • Check for JavaScript errors.
  • Test in all your target browsers. For example, IE7, IE8, IE9, Safari, Chrome, Opera, and Firefox.
  • Clean up any extraneous comments, debug settings, or TODO items.
@AlphaGit
AlphaGit / mongo-faceted-example.js
Created January 3, 2015 21:22
mongo-faceted example
var mongoose = require('mongoose');
var mongoFacets = require('../lib/mongo-facets');
var ExampleSchema = new mongoose.Schema({
stringField: String,
numberField: Number,
arrayOfStringsField: [String]
});
mongoFacets('Example', ExampleSchema);
@AlphaGit
AlphaGit / tardisjsexample.js
Created September 21, 2014 12:43
Example usage of tardis.js
new Date();
// => Thu Aug 28 2014 19:47:15 GMT-0500 (Central Daylight Time)
tardis.travelToFuture(24 * 60 * 60 * 1000);
new Date();
// => Fri Aug 29 2014 19:47:15 GMT-0500 (Central Daylight Time)
tardis.travelToPast(60 * 60 * 1000);
new Date();
// => Fri Aug 29 2014 18:47:15 GMT-0500 (Central Daylight Time)
@AlphaGit
AlphaGit / EmberTestExample.js
Created July 5, 2014 20:42
Example for Ember test
module('My application tests', {
setup: function() {
App = startApp();
},
teardown: function() {
App.destroy();
}
});
test('Click on next page button takes user to next page', function() {
@AlphaGit
AlphaGit / controllerTest.js
Created April 30, 2014 02:45
Decoupled controller for unit testing without depending on $scope too much
describe('Testable controller', function() {
beforeEach(module('MyApp'));
it('should be testable against the controller logic', inject(function($controller, $rootScope, ApiService) {
var $scope = $rootScope.new();
var controller = $controller('MyController', { $scope: $scope, ApiService: ApiService });
expect(controller.generateGreeting).toBeDefined();
var greeting = controller.generateGreeting();
expect(greeting).toBe('...');
@AlphaGit
AlphaGit / simpleConstructor.js
Created April 30, 2014 02:11
Example controller in AngularJS, declared separatedly
var MyController = function($scope, ApiService) {
$scope.awesomeThings = ['everything']; // everything is awesome
$scope.randomStuff = null;
ApiService.getStuff('random').then(function(retrievedStuff) {
$scope.randomStuff = retrievedStuff;
});
};
angular.module('MyApp').controller('MyController', MyController);
@AlphaGit
AlphaGit / fakehr-getpending.js
Last active August 29, 2015 14:00
Get pending requests for fakehr
fakehr.requests.filter(function (r) {
return r.readyState != 4;
}).map(function (r) {
return r.method + ' ' + r.url
});
@AlphaGit
AlphaGit / queueHttpResponder.js
Last active August 29, 2015 14:00
Approach for Ember 1.4+ and emberHttpRespond
var httpResponseQueue = Ember.A();
var checkQueueInterval = null;
var checkQueue = function() {
for (var i = 0; i < httpResponseQueue.length; i++) {
var queuedItem = httpResponseQueue[i];
var found = fakehr.match(queuedItem.verb.toUpperCase(), queuedItem.url);
if (found) {
found.respond(queuedItem.status || 200, {'content-type': 'application/json'}, queuedItem.body);
@AlphaGit
AlphaGit / removeFakeNodes.js
Created April 20, 2014 21:27
Sugiyama algorithm: removing fake nodes
var unlinkFakeNode = function (fakeNode) {
// fake node: remove and connect nodes that it is connecting
var previousNodes = fakeNode.previousNodes.slice(0); // copy since it's going to be modified
previousNodes.forEach(function (previousNode) {
// previous --> next1, previous --> next2, etc
fakeNode.nextNodes.forEach(function (nextNode) {
sugiyamaService.connectNodes(previousNode, nextNode);
});
// previous --X--> fake