Skip to content

Instantly share code, notes, and snippets.

View nowk's full-sized avatar

Yung Hwa Kwon nowk

  • damncarousel
  • New York, NY
View GitHub Profile
// add the filter to your application module
angular.module('yourAppName', ['filters']);
/**
* Truncate Filter
* @Param string
* @Param int, default = 10
* @Param string, default = "..."
* @return string
*/
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
function AttachmentCtrl($scope, $location, $timeout, Docs) {
$(function() {
$('#detail-form-doc').fileupload({
dataType: 'json',
url: '/angular-ib/app/fileupload?id=' + $location.search().id,
add: function(e, data) {
$scope.$apply(function(scope) {
// Turn the FileList object into an Array
for (var i = 0; i < data.files.length; i++) {
$scope.project.files.push(data.files[i]);
@nowk
nowk / uuid.coffee
Created May 31, 2013 19:58
UUID in javascript
# http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
uuid = () ->
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (c) ->
r = Math.random()*16|0
if c == 'x'
v = r
else
v = (r&0x3|0x8)
@nowk
nowk / cache_matcher.rb
Created May 11, 2013 22:38
RSpec cache matcher
RSpec::Matchers.define :have_key do |expected|
def value
@value
end
def cache_record
@cache_record
end
def has_cache_key?
# Here are the settings that are common to all environments
common: &default_settings
# ============================== LICENSE KEY ===============================
# You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the
# New Relic service.
license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
# Agent Enabled (Rails Only)
@nowk
nowk / Gemfile
Last active December 15, 2015 11:18
Development/Test Gems
gem 'chronic'
group :development, :test do
gem 'foreman'
gem 'debugger'
gem 'turn', :require => false
gem 'spork-rails'
# gem 'spork-testunit'
@nowk
nowk / angular-ui-overrides.css.scss
Created March 24, 2013 20:30
Basic overrides for angular-ui (rather not use the jquery ui css)
@import "bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
@import "bootstrap/mixins";
@import "bootstrap/alerts";
@import "bootstrap/type";
@import "bootstrap/tables";
.ui-datepicker {
display: none;
background-color: #fff;
class TablelessModel
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def initialize(attributes = {})
attributes.try(:each) do |name, value|
send("#{name}=", value)
end
end
@nowk
nowk / gist:5215905
Created March 21, 2013 19:26
angularjs module
angular.module("app.Standards", [])
.config(function($httpProvider, $locationProvider) {
$locationProvider.html5Mode(false);
$locationProvider.hashPrefix('!');
$httpProvider.defaults.headers.
common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
})