Skip to content

Instantly share code, notes, and snippets.

Avatar

Dingding Ye sishen

View GitHub Profile
@sishen
sishen / makeapp.sh
Created Nov 12, 2013
Turn website to application using Chrome
View makeapp.sh
#!/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 Jan 13, 2013
The unicorn init.d script to start/stop/restart the service
View unicorn
#!/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 Sep 19, 2012
Sample configuration of mails_viewer to allow the mails real sent to "pragmatic.ly" domain
View mails_viewer_config.rb
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 Aug 16, 2012
Url Scoping in Spine.js
View url_scoping.js.coffee
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 Aug 16, 2012
Sample Spine.js Model in Pragmatic.ly
View project.js.coffee
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 Aug 16, 2012
Sample Spine.js Routing Controller in Pragmatic.ly
View ticket_routing_controller.js.coffee
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 Aug 16, 2012
Sample Spine.js Controller in Pragmatic.ly
View left_iteration_controller.js.coffee
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 Aug 16, 2012
Tree Structure of a real world Spine App
View Pragmatic.ly JS Structure
├── 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 Aug 2, 2012
Web Notifications integration in Pragmatic.ly
View notifier.coffee
class Notifier
constructor: ->
@enableNotification = false
@checkOrRequirePermission()
hasSupport: ->
window.webkitNotifications?
requestPermission: (cb) ->
window.webkitNotifications.requestPermission (cb)
@sishen
sishen / Usage:
Created Jun 4, 2012
Dirty plugin for SpineJS.
View Usage:
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
You can’t perform that action at this time.