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
| # routes rule for ocserv | |
| route = 8.0.0.0/255.0.0.0 | |
| route = 58.0.0.0/255.0.0.0 | |
| route = 23.0.0.0/255.0.0.0 | |
| route = 117.0.0.0/255.0.0.0 | |
| route = 199.0.0.0/255.0.0.0 | |
| route = 190.0.0.0/255.0.0.0 | |
| route = 198.0.0.0/255.0.0.0 | |
| route = 173.0.0.0/255.0.0.0 | |
| route = 174.0.0.0/255.0.0.0 |
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
| #!/bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: ocserv | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| ### END INIT INFO | |
| # Copyright Rene Mayrhofer, Gibraltar, 1999 | |
| # This script is distibuted under the GPL |
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
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
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
| # 在 jQuery 的原型中添加一个新的方法,作为级联选择的插件 | |
| # | |
| # options: | |
| # fetchNextNode: function($node){} 用于如何发现下级控件的回调函数,必须返回节点数组 | |
| # | |
| $.fn.cascadingSelect = (options = {})-> | |
| currentNode = $rootNode = $(this) | |
| otherNodes = options['fetchNextNode']($rootNode) | |
| listenChange = (node)-> |
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
| # #{Rails.root}/config/initializers/active_record/base_decorator.rb | |
| ActiveRecord::Base.class_eval do | |
| def self.human_enum_values(enum_name = nil) | |
| enum_name ||= defined_enums.keys.first | |
| raise "Could not find a enum named #{enum_name} in #{name}" unless enum_values = defined_enums[enum_name] | |
| _human_enum_values = {} | |
| enum_values.each do |key, value| | |
| translated_key = I18n.t "activerecord.enums.#{name.underscore}.#{enum_name}.#{key}" |
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
| # 将参数 {associations_attributes: {"1" => {xxx: xxx}, "2" => {xxx: xxx}}} 中的 Hash 型参数转为数组型: | |
| # => | |
| # { | |
| # associations_attributes: [ | |
| # {xxx: xxx},{xxx: xxx} | |
| # ] | |
| # } | |
| # | |
| # 满足 grape 中 type: Array[OtherTypeName]的验证 | |
| # |
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
| # https://www.digitalocean.com/community/tutorials/how-to-setup-your-own-vpn-with-pptp | |
| # Step 1 - PPTP Installation | |
| sudo apt-get install pptpd | |
| # edit /etc/pptpd.conf and add the following lines: | |
| # localip is IP address of your server and remoteip are IPs that will be assigned to clients that connect to it | |
| localip 10.0.0.1 | |
| remoteip 10.0.0.100-200 | |
| # Step 2 - Add DNS servers to /etc/ppp/pptpd-options |
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
| function isMobileBrowser() { | |
| var userAgent = navigator.userAgent || navigator.vendor || window.opera; | |
| if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibr |
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
| # size - seems to follow this logic | |
| # codes copied from: | |
| # => https://raw.githubusercontent.com/samvincent/rqrcode-rails3/master/lib/rqrcode-rails3/size_calculator.rb | |
| # | |
| # # | input | modules | |
| # | size | created | |
| #-------|-------|-------- | |
| # 1 | 7 | 21 | |
| # 2 | 14 | 25 (+4) | |
| # 3 | 24 | 29 - |
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 XXXController < ApplicationController | |
| def create | |
| moment = Moment.new photo: preprocess_uploaded_photo | |
| # ... | |
| end | |
| def preprocess_uploaded_photo | |
| encoded_photo_data = params[:moment][:photo] | |