Skip to content

Instantly share code, notes, and snippets.

View cloudsben's full-sized avatar
🏠
Working from home

Ben cloudsben

🏠
Working from home
View GitHub Profile
@cloudsben
cloudsben / md-menu.html
Last active June 14, 2023 07:46
markdown menu
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.2/styles/googlecode.min.css">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://yandex.st/highlightjs/6.2/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
$(document).ready(function(){
$("h2,h3,h4,h5,h6").each(function(i,item){
var tag = $(item).get(0).localName;
@cloudsben
cloudsben / VPN.md
Last active May 12, 2019 15:03
vultr VPS 搭建VPN ss

注册地址 (最好是国内的邮箱,我用的是QQ邮箱)

注册地址

安装Shadowsocks 的命令

复制粘贴第一步

wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
@cloudsben
cloudsben / gist:4490135
Created January 9, 2013 02:52
Download an entire website
# -p parameter tells wget to include all files, including images.
# -e robots=off you don't want wget to obey by the robots.txt file
# -U mozilla as your browsers identity.
# --random-wait to let wget chose a random number of seconds to wait, avoid get into black list.
# Other Useful wget Parameters:
# --limit-rate=20k limits the rate at which it downloads files.
# -b continues wget after logging out.
# -o $HOME/wget_log.txt logs the output
wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
@cloudsben
cloudsben / applescript.scpt
Last active October 3, 2016 04:18
URL convert pdf
tell application "Google Chrome"
if not (exists window 1) then reopen
set myBMFolder to bookmark folder "xxx" of bookmark folder "其他书签"
set bmURLs to URL of bookmark items of myBMFolder
repeat with aUrl in bmURLs
tell application "Safari"
tell window 1
open location aUrl
delay 15
@cloudsben
cloudsben / simple_form_association_collection.html.erb
Created August 4, 2016 10:49
simple form association collection option
<%= f.association :country, label: "请选择国家",
disabled: true, collection: Proc.new{ Country.all.map{ |c| [c.name, c.id, {data_country: c.short_name}] } } %>
@cloudsben
cloudsben / is_presence.rb
Last active July 26, 2016 11:50
rails 查询字段是否为验证字段
# 查询字段是否为验证字段,如果是验证字段返回 true
def presence?(poi, field)
presence_fields = poi.constantize.validators.map do |v|
v.attributes if v.is_a? ActiveRecord::Validations::PresenceValidator
end
# 去 nil 并 二维转一维
if presence_fields.compact.flatten.include?(field)
return true
else
return false
@cloudsben
cloudsben / is_presence
Created July 26, 2016 11:39
rails 查询字段是否为验证字段
# 查询字段是否为验证字段,如果是验证字段返回 false 不是 返回 true
def is_presence poi, field
presence_fields = poi.constantize.validators.map do | v |
if v.is_a? ActiveRecord::Validations::PresenceValidator
v.attributes
end
end
# 去 nil 并 二维转一维
if presence_fields.compact.flatten.exclude?(field)
return true
@cloudsben
cloudsben / google-map.js
Created July 18, 2016 04:47
google map 多 marker 自动调整 zoom 显示
// 获取当前列表 经纬度
var latlngMarkerArray = <%= raw @lat_lng.to_json %>;
var markers = [];
var mapOptions = {
zoom: 10,
}
if(latlngMarkerArray.length > 0){
mapOptions['center'] = latlngMarkerArray[0]
}
@cloudsben
cloudsben / oauth2_lib.php
Created October 17, 2012 07:18
codeigniter新浪微博 SDK
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
class Oauth2_lib {
set-option -g prefix 'C-\'
setw -g mode-keys emacs