»

Upgrade Mysql to MariaDB

Log — Tags: , , — Posted by Starck on February 26, 2014

Remove MySQL

Install MariaDB

Rquire.js with Jasmine 2

Coding — Tags: , , , — Posted by Starck on February 21, 2014

Require


Project structure

Project/
│
├── css/
│   └── jasmine.css
├── js/
│   ├── require.js
│   ├── main.js
│   ├── models/
│   │   ├── player.js
│   │   └── song.js
│   └── test
│       ├── spec/
│       │   └── playerSpec.js
│       ├── jasmine.js
│       ├── jasmine-html.js
│       └── boot.js
└── index.html

index.html

main.js

js/models/player.js

js/models/song.js

js/test/spec/playerSpec.js

method

  • toBe()
  • toEqual()
  • .not
  • toMatch(/Regex/)
  • toBeDefined()
  • toBeUndefined()
  • toBeNull()
  • toBeTruthy()
  • toBeFalsy()
  • toContain()
  • toBeLessThan()
  • toBeGreaterThan()
  • toBeCloseTo(e, number)
  • toThrow()
  • spyOn(obj, ‘method’)
    • toHaveBeenCalled()
    • toHaveBeenCalledWith(args…)
    • mostRecentCall

Geraldine Hamilton: Body parts on a chip

Log — Tags: , — Posted by Starck on February 17, 2014

Using start-stop-daemon on CentOS

Log — Tags: , — Posted by Starck on January 19, 2014

Download source

Done!

SSL Certificate Installation on Nginx or Apache

Log — Tags: , , — Posted by Starck on January 11, 2014

SSL Certificate

Before we can sign up for a certificate we have to generate a RSA private key

You will be prompted to provide a passphrase(required). The key file is secured with this passphrase but we will eventually remove this protection.

Then, we will use this private key to generate a certificate signing request which is then submitted to the CA.

Remove the encryption from the RSA private key

Before we start configuring HTTPS Server we have to make sure to remove the passphrase from our RSA key. Otherwise you have to provide the password every time server started.

The unencrypted private key should only be readable by the owner of the Nginx or Apache master process. Most of the time this is the root user:

Generate SSL Certificate

Setting up server

Nginx
Apache

Sigma Global Website

Design — Tags: — Posted by Starck on January 10, 2014


SIGMA_GLOBAL_VISION-2-2

Lens___SIGMA_GLOBAL_VISION-3

Contemporary___SIGMA_17-70mm_F2_8-4_DC_MACRO_OS_HSM___SIGMA_GLOBAL_VISION-3

Concept___SIGMA_GLOBAL_VISION-3

Contemporary___SIGMA_17-70mm_F2_8-4_DC_MACRO_OS_HSM___SIGMA_GLOBAL_VISION-3 2

www.sigma-global.com

Nginx with Apache + FastCGI + PHP-FPM

Coding — Tags: , , , — Posted by Starck on January 10, 2014


Install Apache2 + FastCGI + PHP-FPM

Apache Settings

/etc/apache2/sites-availabe/test.server.com.conf:

/etc/apache2/ports.conf:

Install Nginx

sudo apt-get install nginx

/etc/nginx/sites-available/test:

sudo ln -s /etc/nginx/sites-available/test /etc/nginx/sites-enabled/test

sudo rm /etc/nginx/sites-enabled/default

Restart Server

sudo service nginx restart

sudo service apache2 restart

sudo service php5-fpm restart

Why it’s so dang hard to stick to a resolution

Log — Tags: , — Posted by Starck on January 9, 2014

“Ask yourself what you want for yourself and your life in the next year. What is it that you want to offer the world? Who do you want to be, what do you want more of in your life? And then ask: How might I get there?”

Psychologist Kelly McGonigal explains how to make resolutions that lead to real change:

Building Your Jsbin Service

Log — Tags: , — Posted by Starck on November 2, 2013


  • Install node and npm
  • Install jsbin

    npm install jsbin or npm install -g jsbin

    if have node not found problem, link it to `/usr/bin

    ln -s /usr/local/bin/node /usr/bin/node

  • Clone jsbin project form github

    git clone [email protected]:remy/jsbin.git

  • Jsbin configuration settings

    Go to jsbin project folder

    cp config.default.json config.local.json and modify it. mkdir tmp; mkdir tmp/pids and chmod 777 tmp/pids

  • Install init.d script

    vim /etc/init.d/jsbin and chmod +x /etc/init.d/jsbin

    Change {userid} to your user id.

Update 2014-01-18

Using start-stop-daemon on CentOS

Adding jsbin to run at startup (CentOS)

chkconfig --level 345 jsbin on

Stopping jsbin from running at startup

chkconfig jsbin off

Backbone.js notes

Coding, Log — Tags: , — Posted by Starck on October 18, 2013


Backbone.Events

Method Note
object.on(event, callback, [context]) 註冊監聽一個事件, 並指定觸發 callback, 如果需要在 callback function 中改變 this 的對象, 將對象傳入 context
object.off([event], [callback], [context]) 取消監聽事件, 不指定事件將取消所有的事件

Backbone Event Testing


Backbone.Model

Properties / Method Note
constructor() You can use Backbone.Model.apply(this, arguments) to invoke constructor function of parent class
initialize() If you definean initialize function, it’ll be invoked when the model is created.
defaults Remember that in JavaScript, objects are passed by reference, so if you include an object as a default value, it will be shared among all instances. Instead, define defaults as a function.
attributes If you’d like to retrieve and munge a copy of the model’s attributes, use _.clone(model.attributes) instead.
validate(attrs, options) By default validate is called before save, but can also be called before set if {validate:true} is passed. Return your custom error message, and it will be stored to validateError
isValid() Run validate() to check the model state.
validationError The value returned by validate during the last failed validation.
set()
get()
set(‘attr’, ‘value’) or set({ attr: value})
destroy() You can use _.invoke() to call destroy function for a batch of models. ex: _.invoke(modelsArray, 'destroy')


Backbone.Collection

  • create({ attr: value })
  • fetch()
Properties / Method Note
model
url
models Raw access to the JavaScript array of models inside of the collection.
add
create
reset

Project Template


Backbone.View

Properties / Method Note
tagName
id
className
attributes
el and $el
events
render() A good convention is to return this at the end of render to enable chained calls.


Backbone JS Data Types Primer


Backbone.LocalStorage


Example: TodoList

Backbone TodoList

« Previous PageNext Page »
(c) 2024 Starck Lin | powered by WordPress