Skip to content

Instantly share code, notes, and snippets.

ActiveAdmin.register Event do
#Menu display index
menu :priority => 1
#Scopes
scope :all
scope :pending
scope :approved
scope :rejected
scope :cancelled
@CocaColaCat
CocaColaCat / gist:fbc36659e9de3f2f1bef
Last active September 17, 2015 08:59 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
class Api::V1::AuthTokenController < ApplicationController
include Concerns::AuthTokenConcern
include Concerns::WechatAuthConcern
def get_wechat_token
# 通过 code 来获取 openid
openid = App::AuthProcessor.get_wechat_openid params[:code]
if openid
# 通过 openid 匹配平台账户
angular.module('app.resource')
.factory('AuthToken', ['BaseResource', '$http', 'API_ENDPOINT', '$q',
function (BaseResource, $http, API_ENDPOINT, $q) {
var AuthToken = BaseResource("auth_token");
AuthToken.get_wechat_token = function(code, state){
var deferred = $q.defer();
// 构造 url
var get_wechat_token_url =
API_ENDPOINT+"/get_wechat_token?code="+code+"&state="+state;
angular.module('app.account')
.controller('WechatAuthCtrl',
['$scope', '$location','AuthService', 'Account', 'AuthToken', 'jwtHelper',
function($scope, $location, AuthService, Account, AuthToken, jwtHelper) {
// 获取返回参数 code 和 state
var code = $location.search().code;
var state = $location.search().state;
// 通过 code 来获得签名的 openid
var respond = AuthToken.get_wechat_token(code, state);
angular.module('app',[])
.config([, function(){
//项目列表路由
.state('projects',{
url:'/projects',
templateUrl:"app/project/ProjectList.html",
controller:"ProjectListCtrl",
access:{requireLogin:true}
})
@CocaColaCat
CocaColaCat / gist:f72ab76381b20e12a6c6
Last active August 29, 2015 14:15
SSHKit examples
namespace :tmp do
desc "print env variables"
task :test do
SSHKit.config.default_env = { path: '/usr/local/libexec/bin:$PATH' }
on roles :app do
puts capture(:env)
end
end
desc "remote run head"
@CocaColaCat
CocaColaCat / gist:fe2bd4066b65a63f19b5
Created December 26, 2014 08:02
console inspect rails routing info
routes_set = Rails.application.routes.routes
routes_set.map { |r| p r.path.spec.to_s }
@CocaColaCat
CocaColaCat / challenge-1-7.js
Created November 1, 2012 11:34 — forked from codeschool-courses/challenge-1-7.js
Anatomy of Backbone 1-7
var Appointment = Backbone.Model.extend({});
var appointment = new Appointment();
appointment.set('title', 'My knee hurts');
var AppointmentView = Backbone.View.extend({
render: function(){
$(this.el).html('<li>' + this.model.get('title') + '</li>');
}
});
var appointmentView = new AppointmentView({model: appointment});