Skip to content

Instantly share code, notes, and snippets.

@motephyr
motephyr / gist:e5db9a0682008e9a7e4d88a0f459023e
Created July 10, 2017 08:48
middle2 執行elixir phoenix專案
Aptfile加入
wget
=======================
m2-build.sh chmod 755,加入
export HOME=/root
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb
apt-get update -y
id
binary_id
integer
float
boolean
string
binary
{:array, inner_type}
{:map, inner_type}
map
@motephyr
motephyr / .erb
Last active May 11, 2016 15:23
Vue.js 處理Rails data的filter-view
<%# view fragment %>
<% @topic_categories.each do |category| %>
<li role="presentation"><a v-on:click="one('<%= category.meta_key %>')" aria-controls="<%= category.meta_key %>" role="tab" data-toggle="tab"><%= category.send('name_'+ get_locale) %></a></li>
<% end %>
<tbody id="topics">
<tr v-for="topic in topics">
<td>{{ topic | locale }}</td>
<td>{{ topic.created_at | moment }}</td>
<td>{{ topic.title_zh }}</td>
@motephyr
motephyr / .rb
Last active May 11, 2016 15:54
Vue.js 處理Rails data的filter-controller
...
def index
@topics = Topic.joins(:topic_category).select('topics.id','topics.title_zh','topics.title_en','topics.topic_messages_count','topics.created_at','topic_categories.meta_key','topic_categories.name_zh','topic_categories.name_en')
.order("topics.created_at desc").page(params[:page]).per(10)
@topic_categories = TopicCategory.order("order_date desc")
end
...
@motephyr
motephyr / .jsx
Created March 13, 2016 15:14
AuthenticateComponent
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { pushPath } from 'redux-simple-router';
export function requireAuthentication(Component) {
class AuthenticateComponent extends React.Component {
constructor(props) {
super(props);
}
#osx
brew install graphicsmagick
brew install vips
#linux
sudo aptitude install libvips-dev libmagickwand-dev libxml2-dev
#加裝libxml2在路徑裡
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig
Nginx使用者請看這
由於Let's Encrypt的安裝程式目前還沒有提供nginx模組(其實有在開發,只是還在測試階段),我們依舊可以透過安裝程式自動取得certification後,手動更新nginx的設定黨即可。
首先,我們先取得免費的憑證:
# 如果nginx正在執行中,請先把它關閉
$ sudo -s
$ service nginx stop
$ ./letsencrypt-auto certonly --email 你的email@你的email.net -d freessl.csie.io
@motephyr
motephyr / gist:29f04f24de4ffbe56adc
Last active September 23, 2015 02:51
一些不錯用的sublime package
●sublime_rubocop
Ruby的style guide
●BeautifyRuby
Ruby排版
●Sublime-HTMLPrettify
html,js,css排版
●ERB-Sublime-Snippets
erb用的快速鍵
●sublime-better-coffeescript
coffeescript用的快速鍵
@motephyr
motephyr / gist:0662b8ff09896b5dde3d
Created July 12, 2015 06:22
RubyGem 如何運作的?
大部分的時候,RubyGem都可以直接使用。
但是Ruby有個大問題是:如果出錯的話,你很難找到為什麼出錯。
通常在使用Gem的時候你不會遇到什麼問題,如果運氣不好碰到的話,Google也沒什麼用
如果你不知道Gem到底是怎麼和程式一起運作的話,你就會花很多時間在debug上。
Gem的運作有點像在變魔術,不過花點時間研究,它其實很好懂的。
gem install做了什麼事?
一個Ruby gem只是一些打包起來的code,加上一些額外的data。
@motephyr
motephyr / Readme.md
Created July 8, 2015 09:28
Readme.md

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage