This file contains 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/bash | |
# 2016-5-25 | |
# Init Ubuntu server 16.04 for Rails application | |
# Author: Github@1c7 | |
# Software: | |
# Nginx | |
# MySQL | |
# Git (Capistrano 3 need this) | |
# NodeJS (Rails need this) | |
# Ruby |
This file contains 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
{ | |
"font_size": 10, | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true | |
} |
This file contains 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 query() { | |
var | |
// HN is done with very unsemantic classes. | |
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')), | |
query_list = Array.prototype.slice.call(arguments), | |
shown = 0, total = job_list.length; | |
// Traverses up the dom stack trying to find a match of a specific class | |
function up_to(node, klass) { | |
if (node.classList.contains(klass)) { |
This file contains 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
if "" | |
p 'true' | |
end | |
if 0 | |
p 'true' | |
end |
This file contains 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 -*- | |
# filename: handle.py | |
''' | |
### 环境 | |
python 2.7 + web.py | |
web.py 安装方法是: pip install web.py | |
### 说明 | |
微信公众平台 -> 基本配置 -> 服务器配置 | |
有一个服务器验证的步骤,用这个脚本可以解决 |
This file contains 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
devise_for :users, controllers: { | |
registrations: "user/registrations", | |
omniauth_callbacks: 'omniauth_callback' | |
} |
This file contains 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
# Use this hook to configure devise mailer, warden hooks and so forth. | |
# Many of these configuration options can be set straight in your model. | |
Devise.setup do |config| | |
config.omniauth :wechat, Rails.application.config.open_weixin_app_id, Rails.application.config.open_weixin_app_screct, :authorize_params => {:scope => "snsapi_userinfo"} | |
# .... |
This file contains 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 OmniauthCallbackController < Devise::OmniauthCallbacksController | |
def wechat | |
@user = User.from_omniauth(request.env["omniauth.auth"]) | |
if @user.persisted? | |
sign_in_and_redirect @user, :event => :authentication | |
else | |
session["devise.wechat_data"] = request.env["omniauth.auth"] | |
redirect_to new_user_registration_url | |
end |
This file contains 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
set :path, "/var/www/yuzhu/current" | |
set :bundle_path, "/usr/local/bin/bundle" | |
set :rails_path, "/usr/local/bin/rails" | |
set :output, {:error => "/var/www/random_log/cron_error_log.log", :standard => "/var/www/random_log/cron_log.log"} | |
job_type :my_rails, 'cd :path && :bundle_path exec :rails_path runner -e production :task :output' | |
every 3.hours do | |
my_rails "Location.cal_score" | |
my_rails "Location.cal_price" |
This file contains 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 get_auto_subtitle_xml_url(){ | |
var raw_string = ytplayer.config.args.player_response; | |
var json = JSON.parse(raw_string); | |
var captionTracks = json.captions.playerCaptionsTracklistRenderer.captionTracks; | |
for (var index in captionTracks){ | |
var caption = captionTracks[index]; | |
if(typeof caption.kind === 'string' && caption.kind == 'asr'){ | |
return captionTracks[index].baseUrl + "&fmt=3"; | |
} | |
// ASR – A caption track generated using automatic speech recognition. |