»

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

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

ExpressionEngine Notes

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


Template

取得 channel 的文章, 並顯示 channel custom field 值

if tag

Custom Tags

編寫 Plugin file:

假設我們今天要建立的 Plugin 名稱叫作 Custom

先在 third_party 資料夾底下建立 custom 資料夾 命名為 pi.custom.php .

若發現無法使用 $this->EE->TMPL 時

$this->EE->load->library('template',null,'TMPL');

使用 Template::parse_variables_row

使用 Template::parse_variables

Module

  • upd.module_name.php
  • mcp.module_name.php

mcp 就是 module 的 controller, 假設一個被請求的 url 如下:

admin.php?D=cp&C=addons_modules&M=show_module_cp&module=beyond&method=

C=addons_modules 代表目前的 Controller 是 expression/controllers/cp/addons_modules.php
M=show_module_cp 代表使用該 controller 的 show_module_cp 這個 method
module=beyond 代表被呼叫的 module id名稱為 beyond (third_party/{module_id})
method= 執行該 module controller 的哪一個 method, 未指定預設會導向 index method

透過指定 method 這個 GET 變數,將改變 module controller 呼叫不同的 method, 另外你也可以外部讀取 template 產生不同的 view, 將這些 templates 放置在 module/views 裡, 透過以下在 module controller 的 method 中回傳:

return $this->EE->load->view('template_name', $vars, TRUE);

載入自定義 javascript

  • mod.module_name.php
  • language/english/module_name_lang.php

Language 檔案定義 $lang 語系變數:

語系中 module_name_module_name 和 module_name_module_description 會出現在 MCP 的安裝 modules 列表上

How to create or update a Channel Field?

$this->EE->api_channel_fields->update_field((array) $field_data);

returns: (string) The field_id of the updated/created field.

To Enable Mysql General Log

Log — Tags: — Posted by Starck on October 17, 2013


Edit my.cnf:

You can also rename the general query log file at runtime by disabling the log:

SET GLOBAL general_log = 'OFF';

With the log disabled, rename the log file externally; for example, from the command line. Then enable the log again:

SET GLOBAL general_log = 'ON';


Mysql Reference

How to recursively give directories or files access permissions?

Log — Tags: , , , — Posted by Starck on October 8, 2013


To recursively give directories read & execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +

To recursively give files read privileges:

find /path/to/base/dir -type f -exec chmod 644 {} +


Or, if there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)

chmod 644 $(find /path/to/base/dir -type f)


Or, to reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755

find /path/to/base/dir -type f -print0 | xargs -0 chmod 644

Function.bind

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


你可以利用 function.bind 來改變呼叫函式的對象(this): JS Bin

try starck.callBySelf(); or starck.callByWindow(); in console.


function.bind

For a given function, creates a bound function that has the same body as the original function. In the bound function, the this object resolves to the passed in object. The bound function has the specified initial parameters.

function.bind(thisArg[,arg1[,arg2[,argN]]])

Reference


Callback 的應用: JS Bin try starck.say('hi')

Log Review #1 ( Tutorial HTML CSS jQuery Laravel AngularJS)

Log — Tags: , , , , , , , , — Posted by Starck on August 27, 2013


Laravel


PHP


AngularJS


HTML / CSS


jQuery / JavaScript

CentOS – Linode Longview is not synchronize with your server

Log — Tags: , — Posted by Starck on August 26, 2013


If you got a warning message from linode :

Your system’s clock is fast. Please ensure that ntp is installed and running.

How to solve the problem?

1. Change Time Zone (TZ)

$ sudo cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime

$ sudo vim /etc/sysconfig/clock

change Etc/UTC to Asia/Taipei or yourself

2. Install NTP

$ sudo vim /etc/ntp/step-tickers:

$ sudo service ntpd restart

Done!

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