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
var crypto = require('crypto'); | |
var AESCrypt = {}; | |
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) { | |
encryptdata = new Buffer(encryptdata, 'base64').toString('binary'); | |
var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv), | |
decoded = decipher.update(encryptdata); |
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
<input type="text" name="linkeys[][eui]" class="sign_input"> | |
<input type="text" name="linkeys[][code]" class="sign_input"> | |
params[:linkeys][0] => {"code"=>"597516F5D90924764645C6D25023ECFC", "eui"=>"C8D2C10000000A03"} | |
# 更复杂的嵌套: |
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
# Scenario 1: remote resource returns a binary file; | |
# the last part of the uri represents the file name | |
# e.g. http://someurl.com/artists/jeanlucponty/tracks/elephants-in-love.mp3 | |
class Audio < ActiveRecord::Base | |
has_attached_file :file | |
def file_from_url(url) | |
self.file = download_remote_file(url) | |
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
//第0, 2, 5, 11位为1, 其它位为0 | |
//二进制应该为 010000100101 | |
var digitArray = ['0', '2', '5', '11']; | |
var binByte; | |
for(i=0; i<digitArray.length; i++) { | |
binByte = binByte | 1 << digitArray[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
/** both plugin use same function slider | |
* need rename slider method to resolve the conflicts | |
* */ | |
<script type="text/javascript" src="/javascripts/jslider/jquery.slider-min.js"></script> | |
<script type="text/javascript" src="/javascripts/jslider/jquery.dependClass.js"></script> | |
<script type="text/javascript"> | |
//resolve conflict between jslider and jquery-ui-slider | |
$.fn.myslider = $.fn.slider; | |
delete $.fn.slider; | |
</script> |
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
[ | |
{ "keys": ["ctrl+shift+."], "command": "erb" }, | |
{ "keys": ["ctrl+shift+f"], "command": "reindent"}, | |
{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" } | |
] |
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
module Stringify | |
# When a class includes a module | |
# the module’s self.included method will be invoked. | |
def self.included(base) | |
# Initialize module. | |
end | |
# Requires an instance variable @value | |
def stringify |
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
<%= content_for?(:page_title) ? yield(:page_title) : default_page_title %> |
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 parseISO8601(str) { | |
// we assume str is a UTC date ending in 'Z' | |
var parts = str.split('T'), | |
dateParts = parts[0].split('-'), | |
timeParts = parts[1].split('Z'), | |
timeSubParts = timeParts[0].split(':'), | |
timeSecParts = timeSubParts[2].split('.'), | |
timeHours = Number(timeSubParts[0]), | |
_date = new Date; |
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="broken.png" onerror="this.style.display='none'"/> |