Skip to content

Instantly share code, notes, and snippets.

View araslanov-e's full-sized avatar

Araslanov Evgeny araslanov-e

  • Russia. Tyumen
View GitHub Profile

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

// this is because of http://stackoverflow.com/questions/4398966/how-can-i-hide-select-options-with-javascript-cross-browser/4423543
(function($){
$.fn.extend({detachOptions: function(o) {
var s = this;
return s.each(function(){
var d = s.data('selectOptions') || [];
s.find(o).each(function() {
d.push($(this).detach());

Make /robots.txt aware of the Rails environment

You probably don't want Google crawling your development staging app. Here's how to fix that.

$ mv public/robots.txt config/robots.production.txt
$ cp config/robots.production.txt config/robots.development.txt

Now edit config/routes.rb to add a route for /robots.txt, and add the controller code.

# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("so_test")
end
class Client
include Mongoid::Document
belongs_to :contact
field :name, type: String
# app/constraints/photo_constraint.rb
class PhotoConstraint
def initialize
@types = Photo::TYPES
end
def self.matches?(request)
@types.include?(request.path_parameters[:type])
end
end
@araslanov-e
araslanov-e / gist:6130212
Created August 1, 2013 10:27
Dashboard::DashboardController.ancestors => [Dashboard::DashboardController, Dashboard::ApplicationController, ApplicationController, ... ] Member::MemberController.ancestors => [Member::MemberController, ApplicationController, ... ]
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
end
# app/controllers/dashboard/application_controller.rb
module Dashboard
class ApplicationController < ::ApplicationController
before_filter :authenticate_user!
end
@araslanov-e
araslanov-e / gist:6130213
Created August 1, 2013 10:27
Dashboard::DashboardController.ancestors => [Dashboard::DashboardController, Dashboard::ApplicationController, ApplicationController, ... ] Member::MemberController.ancestors => [Member::MemberController, ApplicationController, ... ]
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
end
# app/controllers/dashboard/application_controller.rb
module Dashboard
class ApplicationController < ::ApplicationController
before_filter :authenticate_user!
end
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@araslanov-e
araslanov-e / gist:6445658
Created September 5, 2013 03:17
Сервис КЛАДР (http://kladr-api.ru/) совместно с Select2 (http://ivaynberg.github.io/select2/)
$("#street").select2
minimumInputLength: 1
ajax:
url: 'http://kladr-api.ru/api.php'
dataType: 'jsonp'
data: (term, page) ->
token: 'token'
key: 'key'
cityId: 'cityId'
query: term