Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dmitry's full-sized avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
@dmitry
dmitry / return_to.rb
Created February 15, 2011 22:55
Return to with query and path name
Rack::Utils.escape(#{request.uri}?#{request.query_string})
@dmitry
dmitry / backbone-mixin.js
Created October 1, 2011 21:49 — forked from wesen/backbone-mixin.js
Merge backbone views (mixin pattern)
/**
* ## Merging mixin views in backbone.js ##
*
* really just more a test for tumblr gistr
*/
/**
* Merge the mixin (a Backbone.View) into another Backbone.View. Automatically merge events, defaults, and call the parent initializer.
**/
function mergeMixin(view, mixin) {
// Allows you to specify events on the data tied to the view in the same way
// that you can specify dom events:
//
// dataEvents: {
// instanceName: {
// 'change:name': 'mothed',
// delete: 'otherMethod'
// }, ...
// }
registerDataEvents: function(unbind) {
@dmitry
dmitry / all.js.coffee
Created October 15, 2011 02:56
Cascade unbind nested views in backbone.js
_.extend Backbone.View.prototype,
renderView: (el, func, view) ->
$.fn[func].call(el, view.render().el)
@views ||= []
@views.push view
disposeViews: ->
if @views
_(@views).each (view) ->
view.dispose()
@dmitry
dmitry / gist:1296732
Created October 18, 2011 21:09
Creating a Backbone.js View Manager
/**
Big thanks to Derick Bailey for his post here:
http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/
*/
(function(Account) {
/** LOTS OF MODEL, COLLECTION, AND VIEW CREATION GOING ON UP HERE, LEFT IT OUT FOR SIMPLICITY */
/**
* Define Routing.
@dmitry
dmitry / sanitize.js
Created October 28, 2011 21:05 — forked from timjb/sanitize.js
HTML Sanitizer for JavaScript
// I'm developing this now as a part of substance (https://github.com/michael/substance)
@dmitry
dmitry / gist:1394872
Created November 26, 2011 02:50 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@dmitry
dmitry / js-oop.js
Created November 30, 2011 05:10
Javascript OOP
(function () {
this.OOP = function(options){
this.constructor.staticVariable++;
this.constructor.staticMethod();
var privateVariable = Math.random();
function privateMethod() {
console.log('privateMethod:');
console.log(privateVariable);
console.log(privateMethodStub());
@dmitry
dmitry / ya-slovari.rb
Created December 4, 2011 17:38
Yandex Slovari (word translation)
%w(rubygems open-uri nokogiri cgi).each {|lib| require lib}
# language directions: en-ru-en de-ru-de fr-ru-fr it-ru-it es-ru-es uk-ru ru-uk kk-ru ru-kk la-ru-la
def translate(text, lang=nil)
url = "http://m.slovari.yandex.ru/search.xml?text=#{CGI::escape(text)}"
url << "&lang=#{lang}" if lang
data = open(url).read
xml = Nokogiri::HTML(data)
@dmitry
dmitry / gist:1503379
Created December 20, 2011 21:34
Manually install nginx + passenger with new pcre
./configure --prefix='/opt/nginx' --with-http_ssl_module --with-cc-opt='-Wno-error' --add-module='/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/nginx' --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-pcre=/root/pcre-8.30
sudo make
make install
rvmsudo rake nginx:clean nginx RELEASE=yes