Skip to content

Instantly share code, notes, and snippets.

View xphong's full-sized avatar
🎯
Focusing

Phong Huynh xphong

🎯
Focusing
View GitHub Profile
@xphong
xphong / Preferences.sublime-settings
Last active May 20, 2016 17:50
Sublime Settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/Seti (SL).tmTheme",
"detect_indentation": false,
"fade_fold_buttons": false,
"font_options":
[
"gray_antialias"
],
@xphong
xphong / .profile
Last active December 3, 2016 15:07
Java/Jython Paths + Aliases
#PATHs
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7.0_72)
export PATH="$JAVA_HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
export JYTHON_HOME=/Users/phonghuynh/jython2.5.3
export PATH=$JYTHON_HOME/bin:$PATH
# Java Environments
alias setJdk6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setJdk7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
// TODO: Add comments
var GRID_BASE = 8,
ySize = parseInt(scope.ysize),
xSize = parseInt(scope.xsize),
startPosition = parseInt(scope.startposition),
quadrantArea = [],
yStartPosition = Math.floor(startPosition / GRID_BASE),
xStartPosition = startPosition % GRID_BASE;
for (i = 0; i < ySize; i++) {
@xphong
xphong / jqueryModule.js
Created July 15, 2015 14:24
Simple module pattern
var moduleName = (function($, window, document) {
'use strict';
var moduleName = {
init: {
}
};
return moduleName;
@xphong
xphong / revealingModule.js
Created July 15, 2015 14:26
Revealing module
var revealingModuleName = (function() {
'use strict';
function methodName() {
}
return {
methodName:methodName
};
@xphong
xphong / namespace.js
Created July 15, 2015 14:27
JS Namespacing
;(function(namespace) {
'use strict';
})(window.namespace = window.namespace || {});
@xphong
xphong / home.spec.js
Created July 15, 2015 14:28
Example karma unit test for ngBoilerplate http://joshdmiller.github.io/ng-boilerplate/#/home
describe('Home Page', function () {
var controller;
beforeEach(module('app.home'));
beforeEach(inject(function ($controller) {
controller = $controller;
controller = $controller('HomeController', {});
}));
@xphong
xphong / getNumberOfBusinessDaysInMonth.js
Created May 4, 2016 16:46
Get number of business days in a selected month with Moment.js
// Usage: getNumberOfBusinessDaysInMonth(moment(), moment().daysInMonth());
function getNumberOfBusinessDaysInMonth(date, days) {
var date = moment(date).startOf('month');
var numberOfBusinessDays = 0;
while (days > 0) {
date = date.add(1, 'days');
if (date.isoWeekday() !== 7 && date.isoWeekday() !== 1) {
numberOfBusinessDays += 1;
}
@xphong
xphong / Packages.md
Created May 20, 2016 19:22
Sublime Text Packages

Installed Packages

  • AngularJS
  • AutoFileName
  • BracketHighlighter
  • ColorHighlighter
  • DocBlockr
  • Emmet
  • ES6
  • GitGutter
@xphong
xphong / app.spec.ts
Created October 14, 2016 17:35
Angular 2 Register/Login Unit Tests for 2.0 Final Version and Release. Code for https://github.com/xphong/registration-app
import { Component } from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { async, inject, TestBed } from '@angular/core/testing';
import { App } from './app.component';
@Component({
template: ''