This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
#正则用于匹配用户名 | |
str = "@wikimo @中國 @水手 测试看看" | |
#{2,20}字符长度至少2个,不多于20个,以下任意方式匹配 | |
#arr = str.scan(/@([一-龠\w]{2,20}\s)/u).flatten | |
arr = str.scan(/@([\p{Han}+\w]{2,20}\s)/u).flatten | |
前端:https://github.com/ichord/jquery-atwho-rails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
<!-- | |
div { | |
position:absolute; | |
top:50%; | |
left:50%; | |
margin:-150px 0 0 -200px; | |
width:400px; | |
height:300px; | |
border:1px solid #008800; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Pre-requisites | |
sudo apt-get -y update | |
sudo apt-get -y install git-core curl autoconf automake openssl vim build-essential libc6-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev mysql-server libmysqlclient-dev ncurses-dev libtool bison libxslt1-dev libxml2-dev | |
# rbenv | |
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile | |
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/views/layouts/_async_javascript.html.erb | |
<script type="text/javascript"> | |
(function() { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.async = true; | |
script.src = '<%= j javascript_path(path) %>'; | |
var other = document.getElementsByTagName('script')[0]; | |
other.parentNode.insertBefore(script, other); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="abc.JPG" onerror="this.src='default.JPG'" /> | |
或者 | |
<script type="text/javascript"> | |
t = document.getElementsByClassName("defaultImg"); | |
for(i = 0; i < t.length; i++){ | |
t.item(i).onerror = function(){ | |
this.src = "test.gif" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_action :detect_device_variant | |
private | |
def detect_device_variant | |
case request.user_agent | |
when /iPad/i | |
request.variant = :tablet | |
when /iPhone/i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title></title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
// 下面的插件部分建议放在js文件中, 方便调用 | |
//-------------- 插件 begin ------------------ | |
(function ($) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.prototype.format = function (format) { | |
/* | |
* eg:format="YYYY-MM-dd hh:mm:ss"; | |
*/ | |
var o = { | |
"M+" : this.getMonth() + 1, // month | |
"d+" : this.getDate(), // day | |
"h+" : this.getHours(), // hour | |
"m+" : this.getMinutes(), // minute | |
"s+" : this.getSeconds(), // second |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- <%= haiku.user.name %> | |
| <%= pluralize haiku.votes, "vote" %> | |
<% if current_user && current_user.can_vote_for?(haiku) %> | |
| <%= link_to "up", vote_haiku_path(haiku, value: 1), method: "post" %> | |
| <%= link_to "down", vote_haiku_path(haiku, value: -1), method: "post" %> | |
<% end %> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
We will create a family tree using just CSS(3) | |
The markup will be simple nested lists | |
--> | |
<div class="tree"> | |
<ul> | |
<li> | |
<a href="#">Parent</a> | |
<ul> | |
<li> |