Skip to content

Instantly share code, notes, and snippets.

View hysios's full-sized avatar
🎯
Focusing

hysios hysios

🎯
Focusing
View GitHub Profile
@hysios
hysios / path-distance.rb
Last active August 29, 2015 14:01
path-distance 1
def distance_between v,w
dist = 0
adj[v].each do |e|
dist = e.weight if e.to == w
end
return dist
end
#receive a path str like "A-B-C", return length of that path
def path_distance str
import Ember from 'ember';
var get = Ember.get;
export default Ember.Component.extend({
didInsertElement: function(){
Ember.$(document).bind('click', this.closeThis);
},
closeThis: function(event) {
@hysios
hysios / index-array.js
Last active August 29, 2015 14:06
ember highlight a item in menu
/* lib/index-array.js */
App.IndexArray = Ember.ArrayController.extend({
_indexName: 'index',
_isVirtual: true,
/**
* initializer function
*
* @param [Array] array proxy target object
zh-cn:
errors:
messages:
not_found: "没有找到"
already_confirmed: "已经确认"
not_locked: "没有锁定"
devise:
failure:
unauthenticated: '继续操作前请注册或者登录.'
unconfirmed: '请先激活您的帐号'
@hysios
hysios / gist:1007949
Created June 4, 2011 14:51
a parse array regexp for javascript
'[10,10,"asdf\\"a,s\\"df","的位图要求asdf",10,10]'.match(/(\d+(?=,?))|(('|")(.+?[^\\]\3)(?=,?))/g);
@hysios
hysios / gist:1240164
Created September 25, 2011 02:51
jQuery Placeholder Text
<script src="jquery.js"></script>
<script src="modernizr.js"></script>
<script>
$(document).ready(function(){
if(!Modernizr.input.placeholder){
$('[placeholder]').focus(function() {
var input = $(this);
@hysios
hysios / gist:1274735
Created October 10, 2011 06:19
shotgun start with thin
Using Thin and starting on port 6000 instead of 9393 (default):
shotgun --server=thin --port=6000 config.ru
豆瓣API key
你的豆瓣 API key:
074048b0e693229415c0da12b3b967bc
API key 的详细信息 · · · · · ·
私钥:f9d8832f4b383bce -请保护好你的私钥
应用名称:Test
应用url:http://localhost
创建时间: 2012-03-04
ni hao a
wrapError = (onError, model, options) ->
(resp) ->
if onError?
onError(model, resp, options);
else
model.trigger('error', model, resp, options)
apply: (name = null, options = {}) ->
name ||= @get('name')
success = options.success