Skip to content

Instantly share code, notes, and snippets.

View Paxa's full-sized avatar

Pavel Evstigneev Paxa

View GitHub Profile
@Paxa
Paxa / 1.html
Created February 24, 2012 03:16
Microdata breadcrumbs test
<!DOCTYPE html>
<html>
<head>
<title>Breadcrumb example - webpage_2.html</title>
</head>
<body>
<section itemscope itemtype='http://schema.org/WebPage'>
<a href='/books'><span itemprop='breadcrumb'>Books</span></a> >
<a href='/books/authors'><span itemprop='breadcrumb'>Authors</span></a> >
<a href='/books/authors/stephen-king'><span itemprop='breadcrumb'>Stephen King</span></a>
@Paxa
Paxa / application.rb
Created November 20, 2011 08:12
Simple background processing
# config/application.rb
def Rails.bg_runner(code)
ruby_cmd = code.gsub(/("|\s)/) {|m| "\\#{m}" }
cmd = %{cd #{Rails.root} && ./script/background #{Rails.env} "#{ruby_cmd}"}
Rails.logger.info "IN BACKGROUND #{cmd}"
Rails.logger.info system(cmd)
end
@Paxa
Paxa / attachment.rb
Created September 8, 2011 03:12
video encoder snippet
class Attachment < ActiveRecord::Base
belongs_to :post
mount_uploader :filename, PostAttachmentUploader
VIDEO_FORMATS = %W{ogv mp4 webm}
PREVIEW_FORMAT = "jpeg"
before_save :set_metas
after_create :start_encoding!, :if => :video?
% bundle exec mida http://lawrencewoodman.github.com/mida/news/
Parsing: http://lawrencewoodman.github.com/mida/news/
---
:type: http://schema.org/Blog
% bundle exec mida -v http://lawrencewoodman.github.com/mida/news/
Parsing: http://lawrencewoodman.github.com/mida/news/
@Paxa
Paxa / 0_example.haml
Created August 25, 2011 07:20
microdata attributes support for rails helpers and haml (requires gem mida)
class Post < ActiveRecord::Base
html_schema_type "http://schema.org/BlogPosting"
end
%article[post, :blogPosts]
= link_to post, :itemprop => "url" do
%h3[:name]>= post.title
.post_body[:articleBody]= post.body.html_safe
// this stuff breaks vkontakte js api
Array.prototype.asdf = function() {
return 'array';
};
VK.init(function() {
VK.api('video.search', {q: 'dfdfd', count: 20}, function(res) {
module Minion
module Daemon
extend self
attr_accessor :pid, :log
def fork_or_skip
arg = ARGV.join(" ")[/\-d\s\d+/] || ARGV.join(" ")[/\-d/]
return unless arg
class Report
class << self
attr_accessor :current
def store(string)
@current ||= new
@current.store(string)
end
@Paxa
Paxa / gist:743270
Created December 16, 2010 10:37 — forked from rwz/gist:743264
var wiget = new Class({
Includes: [Class.MethodMutators],
something: function () {
return new Element('div');
}.mutator('setter'),
onComplete: function () {
this.hide();
}.mutator('bind'),
$('some-link').clk(function(el, event) {
Footer.render('my-friends', Profile.id);
});
var Present = {
id: function(present_id, callback){
if (var present = this.getCached(present_id)) {
callback(present);
} else {
this.fetch(present_id, callback);