取js多选框选中的text值数组
var myarray = $.map($("#pretargeting_mainland option:selected"), function(option){return $(option).text()})
<%= yield.force_encoding('utf-8') %>
检索文件反向删除: rm -rf `ls|egrep -v '(assets|index.html)'`
rm -rf !(test.html)
linux 怎么样复制文件夹内所有文件到另一个文件夹?
cp -Rf /home/user1/* /root/temp/
将 /home/user1目录下的所有东西拷到/root/temp/下而不拷贝user1目录本身。
即格式为:cp -Rf 原路径/ 目的路径/
chop去掉字符串最后一个字符。
strip去掉字符串前后空格。
替换文件全局变量:
find /Users/admin/xmo/public/upload_files/html5/18468/ -name "index.html" -print0 | xargs -0 sed -i 's/x_cnt/x_counter/g'
替换单个文件:
sed -i '' 's/netingcn/www\.netingcn/g' sed_test.txt
正则表达式匹配判断后缀名
@type = preview_url =~ /\.swf$/i ? "flash" : "image"
让程序报错的话,执行下一个请求: rescue next
Order.where("state = ?", "product_assessing_officer_unapproved").each do |order|
order.state = "proof_ready"
order.save(:validate => false) rescue next
end
js获取当前dom节点的第一个父节点查找元素
this.closest("tr")
取浮点数1为:
f=6.3333.round(1)
2.1.2 :012 > f=6.67.round(1)
=> 6.7
2.1.2 :013 > f=6.63.round(1)
=> 6.6
记录用户点击:
function _xmoIstag1(){
var random = Math.random() + "";
var _random = random * 10000000000;
var _opxTAG = document.createElement('script');
_opxTAG.src = "http://webnet/trackingdata?rnum="+random+"&opxUid=0&opxEventID=1240&opxClientID=42&opxcounter=1&opxusername=<%=@current_user.name if @current_user%>";
document.getElementsByTagName('head')[0].appendChild(_opxTAG);
}
html转译符号:
def h_html(s)
h_escape = { '&' => '&', '>' => '>', '<' => '<', '"' => '"', "'" => ''' }
s = s.to_s
s.gsub(/[&"><]/) { |special| h_escape[special] }
end
睡睡念小技巧
猜你喜欢
转载自schooltop.iteye.com/blog/2241616
今日推荐
周排行