Skip to content

Instantly share code, notes, and snippets.

View sishen's full-sized avatar

Dingding Ye sishen

View GitHub Profile
@sishen
sishen / makeapp.sh
Created November 12, 2013 11:03
Turn website to application using Chrome
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@sishen
sishen / unicorn
Created January 13, 2013 15:33
The unicorn init.d script to start/stop/restart the service
#!/bin/sh
set -u
set -e
# Feel free to change any of the following variables for your app:
export PATH=/usr/local/bin:$PATH
export HOME=/home/deploy
APP_ROOT=/var/www/pragmaticly/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
@sishen
sishen / mails_viewer_config.rb
Created September 19, 2012 17:57
Sample configuration of mails_viewer to allow the mails real sent to "pragmatic.ly" domain
config.action_mailer.delivery_method = :file
config.action_mailer.file_settings = {
location: 'tmp/mails',
smtp_settings: {
address: "localhost",
port: 25,
domain: 'localhost.localdomain',
user_name: nil,
password: nil,
authentication: nil,
@sishen
sishen / url_scoping.js.coffee
Created August 16, 2012 17:32
Url Scoping in Spine.js
class App.Ticket extends Spine.Model
@configure 'Ticket', "id", "project_id"
@scope: ->
"projects/#{current.project_id}"
scope: ->
"projects/#{@project_id}"
@sishen
sishen / project.js.coffee
Created August 16, 2012 14:18
Sample Spine.js Model in Pragmatic.ly
class App.Project extends Spine.Model
@configure 'Project', 'id', 'name', 'description', 'owner_id', 'uid'
@extend Spine.Model.Ajax
@extend Spine.Model.Dirty
validate: ->
'name required' unless @name
inviteUser: (email) ->
App.Invitation.create(project_id: @id, email: email)
@sishen
sishen / ticket_routing_controller.js.coffee
Created August 16, 2012 14:16
Sample Spine.js Routing Controller in Pragmatic.ly
class App.TicketsController extends Spine.Controller
constructor: ->
super
@routes
"/tickets": @index
"/tickets/:id" : (params) ->
@show(params.id)
index: ->
tickets = App.Ticket.all()
@sishen
sishen / left_iteration_controller.js.coffee
Created August 16, 2012 14:13
Sample Spine.js Controller in Pragmatic.ly
class App.LeftIterationController extends Spine.Controller
el: '.sidebar #iterations'
elements:
'ul.list': 'list'
constructor: ->
super
App.Iteration.bind 'create', @addIteration
App.Iteration.bind 'refresh', @refreshIterations
@sishen
sishen / Pragmatic.ly JS Structure
Created August 16, 2012 14:09
Tree Structure of a real world Spine App
├── app
│   ├── controllers
│   │   ├── center
│   │   │   ├── filter_controller.js.coffee
│   │   │   └── tickets_controller.js.coffee
│   │   ├── center_content_controller.coffee
│   │   ├── comments_controller.js.coffee
│   │   ├── header
│   │   │   └── project_nav_controller.js.coffee
│   │   ├── header_controller.coffee
@sishen
sishen / notifier.coffee
Created August 2, 2012 03:36
Web Notifications integration in Pragmatic.ly
class Notifier
constructor: ->
@enableNotification = false
@checkOrRequirePermission()
hasSupport: ->
window.webkitNotifications?
requestPermission: (cb) ->
window.webkitNotifications.requestPermission (cb)
@sishen
sishen / Usage:
Created June 4, 2012 05:44
Dirty plugin for SpineJS.
So the model object can bind the event "change:#{field} to trigger event when the field value is changed.
By default it's off and if need this feature, the model should extend Spine.Model.Dirty.
A sample case.
class User extends Spine.Model
@extend Spine.Model.Dirty
end