Skip to content

Instantly share code, notes, and snippets.

$("<%= escape_javascript render(:file => 'comments/new.html.erb') %>").insertAfter('#comments');
$('#new_comment').slideDown();
$('#new_comment_link').hide();
require 'open-uri'
if Dir[@store_path+"*"].empty?
`rmdir #{@store_path}`
end
File.basename(url)
@kkxlkkxllb
kkxlkkxllb / nginx.conf
Created October 25, 2012 06:22
rails unicorn nginx config file cache
if (-f $request_filename) {
break;
}
if (-f $document_root/cache/$uri/index.html) {
rewrite (.*) /cache/$1/index.html break;
}
if (-f $document_root/cache/$uri.html) {
rewrite (.*) /cache/$1.html break;
url = "http://www.wikipedia.org"
doc = Nokogiri::HTML(open(url))
icon = doc.search("link[@rel='shortcut icon']") | doc.search("link[@rel='icon']")
@icon_urls = icon.map {|i| i.attributes["href"].value()}
class RecordingEpg
RSID = "SCSP"
TSID = "ISPACE DS"
def self.get_epg(args={})
args = {
:spid => $rca_config[:kuanyun_spid],
:appid => $rca_config[:kuanyun_appid],
:time_stamp => Date.today.to_time.strftime('%Y-%m-%d %H:%M:%S'),
On only two scores can The Economist hope to outdo its rivals
consistently. One is the quality of its analysis; the other is the quality
of its writing. The aim of this book is to give some general advice on
writing, to point out some common errors and to set some arbitrary
rules.
The first requirement of The Economist is that it should be readily
understandable. Clarity of writing usually follows clarity of thought.
So think what you want to say, then say it as simply as possible. Keep
in mind George Orwell’s six elementary rules (“Politics and the English
Language”, 1946):
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$ ->
$("form#form_test").bind "ajax:success",(data, cdata, xhr) ->
if cdata.status is 0
alert("ss")
tmpl = $('#tmpl-item').html()
todoItemHTML = (id, txt) ->
main = exports ? this
main.searchLocations = (brand, cities...) ->
a = "looking for #{brand} in #{cities.join(',')}"
console.log(a)
class main.Coffee
constructor: (@name, @strength=1) ->
$("i.icon-leaf").click =>
console.log(@name)
brew: -> alert "brewing #{@name}"
pour: (amount=@strength) ->
@kkxlkkxllb
kkxlkkxllb / player.js.coffee
Last active December 10, 2015 22:18
simple html5 video player, custom video control,volume control with keyboard
$.fn.vod_player = (options) ->
timeFormat = (seconds) ->
m = if Math.floor(seconds/60) < 10 then ("0" + Math.floor(seconds/60)) else Math.floor(seconds/60)
s = if Math.floor(seconds-(m*60)) < 10 then ("0" + Math.floor(seconds-(m*60))) else Math.floor(seconds-(m*60))
m + ":" + s
defaults =
width: 1280
height: 720
source: "http://itstreaming.apple.com/podcasts/apple_keynotes_1080p/2012_oct_1080_CC.m4v"
type: 'video/mp4'
#cover
width: 600px
padding: 40px
position: absolute
left: 0
-webkit-perspective: 920px
-webkit-perspective-origin: 50% 50%
.cover-frame
position: relative
width: 333px