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
@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;
@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'
# 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 / 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?
@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)
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]);
// 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!"
// add the filter to your application module
angular.module('yourAppName', ['filters']);
/**
* Truncate Filter
* @Param string
* @Param int, default = 10
* @Param string, default = "..."
* @return string
*/
@nowk
nowk / formtastic-inline-errors.js.coffee
Last active December 19, 2015 02:09
Angular.js directive for inline form errors when using Formtastic
angular.module("app", [])
.directive 'formtasticInlineErrors', ($compile) ->
return {
restrict: 'A'
link: (scope, element, attrs) ->
scope.$on 'event:form-FormErrors', (evt, model_name, errors) ->
element.find('.input .inline-error').remove()
if !errors? || errors.length == 0
else
@nowk
nowk / aws_S3.rb
Last active December 20, 2015 06:39
Amazon S3 request generator class
class AwsS3
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY_ID']
AWS_SECRET_KEY = ENV['AWS_SECRET_ACCESS_KEY']
S3_BUCKET = ENV['S3_BUCKET'] || "#{Rails.application.class.parent_name}_#{Rails.env}".downcase
attr_accessor :file_name, :mime_type, :path, :acl, :expires_in
attr_writer :as_attachment
def initialize(file_name, mime_type, acl: 'private', path: '/')
@file_name = esc file_name # escape for spaces and the like