Skip to content

Instantly share code, notes, and snippets.

View iolo's full-sized avatar

Dongsu Jang iolo

View GitHub Profile
@iolo
iolo / typeahead.js
Created October 14, 2014 14:02
simple angular directive to support twitter's typeahead.js
angular.module('io.utils', [])
module.directive('ioTypeahead', [
'$parse',
function ($parse) {
return {
restrict: "AE",
replace: true,
transclude: false,
compile: function (element, attrs) {
var modelAccessor = $parse(attrs.ioTypeahead);
@iolo
iolo / parserelaxjson.js
Created October 14, 2014 13:52
angularJS factory example: parse relax json string with not quoted property key
angular.module('io.utils', [])
.factory('parseRelaxJson', [function () {
// XXX: 대충 만들었음... 제대로 할라믄 귀찮아... 글타고 라이브러리 가져다 쓰기도 그렇고...
// `{abc:` --> `{"abc":` or `,abc:` --> `,"abc":`
var PROPERTY_KEY_RELAX = /(\{|,)\s*(.+?)\s*:/g;
var PROPERTY_KEY_STRICT = '$1"$2":';
return function (str) {
try {
return JSON.parse(str);
} catch (e) {
@iolo
iolo / prettyjson.js
Created October 14, 2014 13:49
AngularJS filter example: pretty print for json object.
angular.module('io.utils', [])
.filter('prettyJson', [function () {
return function (obj, pretty) {
if (!obj) {
return '';
}
var json = angular.toJson(obj, pretty);
if (!pretty) {
return json;
}
@iolo
iolo / 0_test-schema.sql
Last active August 29, 2015 14:06
Node Mysql - The Pyramid of Doom
DROP TABLE IF EXISTS accounts;
CREATE TABLE accounts (name VARCHAR(100), balance INT);
INSERT INTO accounts VALUES('foo', 100);
INSERT INTO accounts VALUES('bar', 200);
INSERT INTO accounts VALUES('baz', 300);
INSERT INTO accounts VALUES('qux', 400);
SELECT * FROM accounts;
@iolo
iolo / debug_browser.js
Created October 7, 2013 16:56
[visionmedia debug](https://github.com/visionmedia/debug) clone for browser environment.
var debugEnabledTags = [];
var debugDisabledTags = [];
(window.DEBUG || '*').split(/[\s,]+/).forEach(function (tag) {
tag = tag.replace('*', '.*?');
if (tag[0] === '-') {
debugDisabledTags.push(new RegExp('^' + tag.substr(1) + '$'));
} else {
debugEnabledTags.push(new RegExp('^' + tag + '$'));
@iolo
iolo / detect_browser.js
Created October 7, 2013 16:37
quick and dirty browser detection
function detectBrowser() {
var name = navigator.appName;
var version = navigator.appVersion;
var ua = navigator.userAgent;
var nameMatches = ua.match(/(chrome|safari|firefox|msie|opera)\/?\s*(\.?\d+(\.\d+)*)/i);
if (nameMatches) {
name = nameMatches[1];
var versionMatches = ua.match(/version\/([\.\d]+)/i);
if (versionMatches) {
diff -uNr node_modules/mongoose-3.6.14/History.md node_modules/mongoose/History.md
--- node_modules/mongoose-3.6.14/History.md 2013-07-06 07:16:15.000000000 +0900
+++ node_modules/mongoose/History.md 2013-07-17 04:07:52.000000000 +0900
@@ -1,4 +1,13 @@
+3.6.15 / 2013-07-16
+==================
+
+ * added; mongos failover support #1037
+ * updated; make schematype return vals return self #1580
// truncatechars 필터 정의
angular.module('filters', [])
.filter('truncatechars', function() {
return function(text, maxlen) {
return (text.length - 3 < maxlen)
? text
: text.substring(0, maxlen-3) + '...';
};
});
// my-rating 지시자 정의
angular.module('directives', [])
.directive('my-rating', function() {
return function(scope, element, attrs) {
var tags = '';
var n = (isNaN(attrs.myRating)
? 0 : parseFloat(attrs.myRating);
for (var i = 0; i < 5; i++) {
var suffix = ((i < n) ? 'full' : 'empty');
tags += '<img src="star-' + suffix + '.png" />';
<html ng-app="app">
<body ng-controller="mainCtrl">
<header>
<div ng-include="'common-header.html'"></div>
<div ng-show="currentUser">
<p>Welcome, {{currentUser.userame}}!</p>
<button ng-click="logout()">Logout</login>