tag:blogger.com,1999:blog-57588754166263407172024-02-19T09:34:14.016+08:00PHP 程式 學習 筆記本個人學習程式與網路收集資料BLOG,期待與大家教學相長...
「設計的核心是溝通」
「溝通的核心是故事」千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.comBlogger919125tag:blogger.com,1999:blog-5758875416626340717.post-46696610419907354582016-09-10T10:30:00.005+08:002016-09-10T10:30:56.759+08:00bootstrap 圖片居中 img-responsive center-block來源網址: http://www.devdo.net/bootstrap3-img-align-center.html
<img src="圖片地址" class="img-responsive center-block" />
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-81020169461296161202016-05-26T10:47:00.002+08:002016-05-26T10:47:41.320+08:00Http Status Code
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-56687925381903821082016-02-18T15:25:00.000+08:002016-02-18T15:25:20.903+08:00[Rails Error] rubygems/core_ext/kernel_require.rb in `require': cannot load such file -- bundler/setup (LoadError)在自己的環境下執行 bundle exec rails c 時,
出現下列錯誤:
rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
後來找了一下google 才找到解法:
bundle install --binstubs
詳細解說:
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-56767632634899581392016-02-17T12:22:00.002+08:002016-09-22T17:48:50.284+08:00[推薦]DigitalOcean VPS 每月只要 $5 美金, 還先送你 $10
按此網址前往註冊,可獲得10美元的使用金【DigitalOcean】
步驟1:DigitalOcean
註冊帳號, 並且到信箱點擊驗證信連結.
步驟2: 輸入信用卡資訊 or Paypal (paypal 第一次需要先刷$5 )
結果如下:
另外若是你推薦其他人使用, 若是該用戶在 DigitalOcean 花$25 , 你將得到$25.
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-57670377753089846922016-02-03T12:02:00.001+08:002016-02-03T12:14:50.377+08:00[Rails] 運用 Net::HTTP and URI
http = if Recaptcha.configuration.proxy
proxy_server = URI.parse(Recaptcha.configuration.proxy)
Net::HTTP::Proxy(proxy_server.host, proxy_server.port, proxy_server.user, proxy_server.password)
else
Net::HTTP
end
query = URI.encode_www_form(verify_hash)
uri = URI.parse(Recaptcha.configuration.verify_url + '?' + query)
http_instance = http.new(uri.host, uri.port)
http_instance.read_timeout =千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-20109678430056992892016-02-03T10:53:00.001+08:002016-02-03T10:59:25.815+08:00[Rails] require: cannot load such file -- bundler/setup (LoadError) Error messages : require: cannot load such file -- bundler/setup (LoadError)
如果出現以上訊息.
請執行下列方式.
remove Gemfile.lock
bundle install
bundle exec rake rails:update:bin千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-84580814536229074142016-01-26T16:19:00.001+08:002016-01-26T16:19:17.941+08:00Ruby &block lambda proc yield 使用基本 Lambda
hello = lambda { puts "Hello" }
hello.call
Result : Hello
log = lamba { |str| puts "[Log] #{str}"}
log.call ("Test message")
Result : [Log] Test message
Lambda Factory 模式
def times_n (n)
lambda { |x| x * n }
end
a=times_n(10)
a.call(5)
Result : 50
b=times_n(15)
b.call(10)
Result : 150
[1,2,3].collect(&b)
Result :
[
[0] 150,
&千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-20412704697509276582016-01-08T16:07:00.001+08:002016-01-08T16:07:25.464+08:00使用 pjax 進行頁面加速這篇介紹 Pjax 還不錯.... https://phphub.org/topics/44
當中也有美化在load pjax 頁面時的一些動畫.
使用 rstacruz/nprogress 來實現.
添加的方法是 下載 文件, 然後把 nprogress.js 和 nprogress.css 添加到頁面中千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-9487673237322422622016-01-07T09:40:00.001+08:002016-01-07T09:56:31.348+08:00[Rails] ActiveRecord::Enum 神奇的 enum 功能.
http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html
可以用這個gem 取代 https://github.com/brainspec/enumerize
class Conversation < ActiveRecord::Base
enum status: [ :active, :archived ]
end
# conversation.update! status: 0
conversation.active!
conversation.active? # => true
conversation.status # => "active"
# conversation.update! status: 1
conversation.archived!
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-79600142489144980412016-01-07T09:11:00.002+08:002016-01-07T09:11:23.329+08:00GoogleTranslate 大絕招.
哇這是什麼絕招啊~~~
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-12064757475688751252015-12-10T15:37:00.002+08:002015-12-10T15:37:26.718+08:00[CSS3] justify-content 使用來源網址: http://css.doyoe.com/properties/flex/justify-content.htm
justify-content:flex-start | flex-end | center | space-between | space-around
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>CSS参考手册</title>
<meta name="author" />
<style>
h1{font:bold 20px/1.5 georgia,simsun,sans-serif;}
.box{
display:-webkit-flex;千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-52263794292514703592015-11-30T19:38:00.002+08:002015-11-30T19:42:58.273+08:00[引用]讓 ul 置中
來源: http://muki.tw/tech/ul-align-center-in-css/
我們常利用ul做選單、做列表、做頁碼 …等等,但會碰到一種狀況,是想讓ul置中,如果你直接寫text-align:center會發現ul完全不鳥你!
這是因為ul預設為display:block,所以如果想讓他置中,必須更改他的display狀態。
<div class="wrap">
<ul>
<li>Hello</li>
<li>World</li>
</ul>
</div>
.wrap {
text-align: center;
}
.wrap ul {
display: inline-block;
}
若是沒有上一層, 則給他一個千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-45302597701257278022015-11-28T14:39:00.001+08:002015-11-28T14:41:42.381+08:00addEventListener、attachEvent 在別的程式中看到, 建立一個iframe, 並且addEventListener "load" , 然後在執行 handleResult function.
這邊有詳細解說
if(!ajaxframe) {
var div = document.createElement('div');
div.style.display = 'none';
div.innerHTML = '<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '" loading="1"></iframe>';
$('append_parent').appendChild(div);
ajaxframe = $(ajaxframeid);
} else if(ajaxframe.loading) {
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-10405713581912138022015-11-05T09:59:00.000+08:002015-11-05T09:59:07.678+08:00Ruby [ class variable, class instance variable, instance variable]所以
@a 是 class variable
@b 是 class instance variable
@c 是 instance variable
class Hi
@@a = 1 # class variable
@b = 2 # class instance variable
def initialize
@c = 3 # instance variable
end
def test # instance method, works on objects of class A
puts @@a # => 1
puts @b # => nil, there is no instance variable @b
puts @c # => 3 # we defined this instance 千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-41787708228899073482015-10-30T08:43:00.005+08:002015-10-30T08:43:41.255+08:00引用自: Tsung's Blog
詳見:Oracle Announces General Availability of MySQL 5.7
MySQL 5.7 GA Release 釋出
MySQL 5.7 的特色如下:(What’s New in MySQL 5.7)
3x Faster Performance
New Optimizer
Native JSON Support
Multi-source Replication
GIS Spatial Extensions
And other important enhancements
MySQL 5.7 的 Benchmarks 可見:MySQL :: Benchmarks
官方新聞
MySQL Server Blog
Storing UUID Values in MySQL Tables
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-50873872817041799782015-10-28T16:19:00.001+08:002015-10-28T16:19:24.780+08:00Rails 4 class method 使用 alias_attribute, alias_method_chain, delegate, mattr_accessor很需要了解並且熟悉這些method 的用法http://api.rubyonrails.org/classes/Module.html#method-i-mattr_accessor
Methods
A
alias_attribute,
alias_method_chain,
anonymous?,
attr_internal,
attr_internal_accessor,
attr_internal_reader,
attr_internal_writer
C
cattr_accessor,
cattr_reader,
cattr_writer
D
delegate,
deprecate
F
foo
M
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-59088326710005332942015-10-08T11:14:00.004+08:002015-10-08T11:14:31.481+08:00Google Gmail 得 IMAP, SMTP, POP3 與降低安全性設定
Google Gmail 得 IMAP, SMTP, POP3 得設定值, 整理如下:
IMAP
imap.gmail.com
Port: 993
Use SSL: Yes
SMTP
smtp.gmail.com
Port for TLS/STARTTLS: 587
Port for SSL: 465
POP3
pop.gmail.com
Port: 995
Use SSL: Yes
PHPMailer 使用 Gmail 寄信登入失敗的設定修復
PHPMailer 的程式不需要修改,也沒什麼特別要做的,在此就不特別提供 Code。
主要無法正常成功登入的原因如此頁面說明: 無法登入我使用的電子郵件應用程式
您使用的郵件應用程式可能不支援最新的安全性標準。建議您變更部分相關設定,允許安全性較低的應用程式存取您的帳戶。
修復設定(降低安全性設定)
於此處千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-73918188704136619992015-07-16T20:27:00.001+08:002015-07-16T20:29:22.404+08:00純CSS tooltip Demo : http://codepen.io/anon/pen/aOjbgq
沒想到Css 也能透過 <div data-tooltip="提示資訊">XXX</div>
來呈現tooltip , Css 真是太威了.
[data-tooltip] {
position: relative;
z-index: 2;
cursor: pointer;
}
/* Hide the tooltip content by default */
[data-tooltip]:before,
[data-tooltip]:after {
visibility: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-32527460262347171322015-07-06T10:24:00.001+08:002015-07-06T10:24:35.369+08:00CentOS 6 升級 git
來源: http://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-xStep 1: Install Required Packages
Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-58007173122071028342015-07-01T09:40:00.000+08:002015-07-01T11:23:09.244+08:00用Js setAttribute 寫css 速度差異.用Js 寫css 速度差異. http://jsfiddle.net/XmW49/455/
var thing = document.getElementById("first");
console.time("first");
thing.setAttribute("style", "width: 100px; height: 100px; background-color: block;");
console.timeEnd("first");
var thing3 = document.getElementById("thing-3");
console.time("green");
thing3.style.cssText = "width: 100px; height: 100px; background-color: green;";
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com1tag:blogger.com,1999:blog-5758875416626340717.post-91209067202709612432015-06-03T16:58:00.002+08:002015-06-03T17:01:41.348+08:00An ActionDispatch::RemoteIp::IpSpoofAttackError 10.xx.xx.xx發生環境 Ruby 1.9.3 and Rails 3.2.20
若是你要讓 10.xxx.xxx.xxx 的ip 可以通過驗證.
方法一:
config.action_dispatch.ip_spoofing_check = false
方法二:
class ActionDispatch::RemoteIp
self.send :remove_const, "TRUSTED_PROXIES"
TRUSTED_PROXIES = %r{
^127\.0\.0\.1$ |
^(172\.(1[6-9]|2[0-9]|3[0-1]) |
192\.168
x)\.
}
end
若是在 rails 4.0 以上, 可以用下列方式.
千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-23387960626309857702015-05-25T15:27:00.004+08:002015-05-25T15:27:51.884+08:00How to fix Amazon S3-RequestTimeTooSkewed安裝 ntp
apt-get install ntp oryum install ntp
打開下列檔案
vim /etc/ntp.conf
最後面加入: server 0.amazon.pool.ntp.org iburstserver 1.amazon.pool.ntp.org iburstserver 2.amazon.pool.ntp.org iburstserver 3.amazon.pool.ntp.org iburst
重啟 NTP
service ntpd restart or
/etc/init.d/ntp restart
取得GMT time
date -u
測試連到s3 server , 打下列兩行指令
telnet s3.amazonaws.com 80GET / HTTP/1.0千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-61689898323428620382015-04-20T17:10:00.001+08:002015-08-13T11:10:11.306+08:00[javascript] Call , Apply , Bind 用法https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this
Apply: 來源
function callMe(arg1, arg2){
var s = "";
s += "this value: " + this;
s += "<br>";
for (i in callMe.arguments) {
s += "arguments: " + callMe.arguments[i];
s += "<br />";
}
return s;
}
document.write("Original function: <br/>");
document.write(千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-12711950074655667502015-04-01T09:40:00.000+08:002015-05-13T09:46:05.429+08:00[引用]PHP上處理utf-16le檔案來源出處: http://www.jikker.net/2010/11/phputf-16le.html
只有utf-8允許可以沒有bom,utf-16, utf-32都是一定要有bom的,因為牽涉到little endian跟big endian的問題
function utf8_to_utf16($utf8_filename,$utf16_filename){
$file = fopen($utf8_filename,"r");
$write = fopen($utf16_filename,"w+");
if($file){
$buffer=chr(255).chr(254); //加入BOM
fwrite($write,$buffer);
while(($buffer = fgets($千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0tag:blogger.com,1999:blog-5758875416626340717.post-74387005953409445062015-03-26T12:05:00.004+08:002015-03-26T12:06:17.164+08:00Rails 3.2.20 redirecting class 內的 _compute_redirect_to_locationRails 3.2.20 中的 redirecting.rb
/actionpack/lib/action_controller/metal/redirecting.rb
會什麼可以吃這麼多種設定呢?
# Examples:
# redirect_to :action => "show", :id => 5
# redirect_to post
# redirect_to "http://www.rubyonrails.org"
# redirect_to "/images/screenshot.jpg"
# redirect_to articles_url
# redirect_to :back
# redirect_to proc { edit_post_url(@千江有水千江月http://www.blogger.com/profile/09457834533843066844noreply@blogger.com0