Skip to content

Instantly share code, notes, and snippets.

View cemeng's full-sized avatar
💭
aw yis

Felix Tjandrawibawa cemeng

💭
aw yis
View GitHub Profile
@cemeng
cemeng / gist:1ddda08179da451138e3
Created January 23, 2015 03:40
VIM keystrokes for editing strip report
:g/^\s\+$/d
:%s/^/{ description: "/g
:%s/\s\+(pull down menu) /", option_id: "/g
:%s/\s\+\(\w\+\)$/", part_id: "\1" },/g
@cemeng
cemeng / gist:54a1904708a937fc983e
Created January 6, 2015 23:02
Use angular one time binding
Jobs
Before:
All: 1036 341.65
P: 1040 213.11
S: 1036 229.69
T: 1036 196.76
After:
All: 553 229.92
P: 552 219
@cemeng
cemeng / gist:5693029
Created June 2, 2013 08:30
Logrotate Rails logs
@cemeng
cemeng / gist:4078252
Last active October 12, 2015 19:48
Mac Fresh Install
  • Download Chrome first

From Appstore - install:

  • XCode - this might take a while ** When done install the command line tool from XCode
  • ColorSchemer
  • LiveReload

Install the following from their websites:

@cemeng
cemeng / gist:4062897
Created November 12, 2012 23:54
Captive Runtime Native Updater
http://stackoverflow.com/questions/9533436/how-to-create-updater-for-air-application-bundled-with-captive-runtime
http://code.google.com/p/nativeapplicationupdater/
http://www.riaspace.com/2010/10/building-nativeapplicationupdater-custom-ui/
http://help.adobe.com/en_US/air/build/WSfffb011ac560372f709e16db131e43659b9-8000.html
Clean up
How to cd to the batch file directory
@cemeng
cemeng / gist:3830781
Created October 4, 2012 00:29
Angular Service and Factory
class @JobInvoice
  constructor: (preloadedInvoice) ->
    angular.extend(this, preloadedInvoice)
    @saveURL = "/job_invoices/update/#{@id}.json"
  subTotal: ->
    @items.
      map((i) -> i.quantity * i.unit_price).
      reduce ((sum, price) -> sum + price), 0
 addItem: (item) ->
@cemeng
cemeng / gist:3830457
Created October 3, 2012 23:06
Passing Rails variable/data to Coffeescript/Javascript

My problem

I need to access data from rails controller - currently, in my view I do this view.erb

app.factory "preloadedInvoice", ->
  <%= raw @job_invoice.to_json %>.job_invoice;

and this will allow preloadedInvoice to bebe used on the coffee/js file:

@cemeng
cemeng / gist:3792335
Created September 27, 2012 05:35
thin vs fat arrow in CoffeeScript
@http.put(@saveURL, @toServerFormat())
  .success (data) ->
    @loadJobInvoiceItems data.job_invoice.items

JobInvoice.prototype.save = function(doNotifyOfSave) {
  return this.http.put(this.saveURL, this.toServerFormat()).success(function(data) {
    this.loadJobInvoiceItems(data.job_invoice.items);
    if (doNotifyOfSave && typeof notifyOfSave === "function") {
      return notifyOfSave(this.job.id);

}

@cemeng
cemeng / gist:3740964
Created September 18, 2012 02:45
Testing Angular w/ Jasmine in CoffeeScript
Useful resources:
- https://github.com/GoogleChrome/textdrive-app - the test is written in CoffeeScript
- http://docs.angularjs.org/tutorial/step_05 - read the testing bit, test written in JS
Things to know:
- You must include angular-mock.js library
-
@cemeng
cemeng / gist:3711831
Created September 13, 2012 04:23
Angular HTTP save
```
# Set http authorization for all http (ajax) calls
credentials = $("#credentials").val();
if (credentials != "")
$http.defaults.headers.common['Authorization'] = credentials
$scope.deleteOnZeroQuantity = (item) ->
if item.quantity is "0"
$scope.job_invoice.items.splice $scope.job_invoice.items.indexOf(item), 1