Skip to content

Instantly share code, notes, and snippets.

View 1c7's full-sized avatar

ZhengCheng 1c7

View GitHub Profile
@1c7
1c7 / ubuntu14.04-rails-setup.sh
Last active May 25, 2016 07:59
Setup Ubuntu 14.04 server for Rails application (I use this to setup UCloud Ubuntu server)
#!/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
{
"font_size": 10,
"tab_size": 2,
"translate_tabs_to_spaces": true
}
@1c7
1c7 / hn_seach.js
Created August 12, 2016 06:05 — forked from kristopolous/hn_seach.js
hn job query search
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)) {
if ""
p 'true'
end
if 0
p 'true'
end
# -*- coding: utf-8 -*-
# filename: handle.py
'''
### 环境
python 2.7 + web.py
web.py 安装方法是: pip install web.py
### 说明
微信公众平台 -> 基本配置 -> 服务器配置
有一个服务器验证的步骤,用这个脚本可以解决
devise_for :users, controllers: {
registrations: "user/registrations",
omniauth_callbacks: 'omniauth_callback'
}
# 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"}
# ....
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
@1c7
1c7 / whenever_schedule.rb
Created November 2, 2017 09:43
this one work for me! 2017!
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"
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.