This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter :set_temp_attachable_id, :prepare | |
private | |
def prepare | |
@categories = Category.all | |
@team = User.public.limit(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\''' | |
alias open='xdg-open' | |
function mcd() { | |
mkdir -p "$1" && cd "$1"; | |
} | |
# Quick jump n directories | |
alias ..1='cd ..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cur.choosePhotoMulti('788157_300811274', | |
cur.chooseMedia.pbind( | |
'photo', '788157_300811274', | |
{"thumb_s": "http:\/\/cs312723.vk.me\/v312723157\/4b4\/LNWtqCWn4O8.jpg", | |
"thumb_m": "http:\/\/cs312723.vk.me\/v312723157\/4b8\/FO0Wdm8W5TY.jpg", | |
"list": "d3d9abe7e6b009e846", | |
"view_opts": "{temp:{base:\"http:\/\/cs312723.vk.me\/v312723157\/\",x_:[\"4b5\/h3WLDKISxr4\",100,100]}}", | |
"editable": { | |
"sizes": { | |
"s":["http:\/\/cs312723.vk.me\/v312723157\/4b4\/LNWtqCWn4O8.jpg",75,75], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [ | |
{"created_at":"2013-03-07T12:24:06Z","id":49,"name":"Бегичева, улица","region_id":3,"updated_at":"2013-03-07T12:24:06Z"}, | |
{"created_at":"2013-03-07T12:24:06Z","id":359,"name":"Беговая аллея","region_id":8,"updated_at":"2013-03-07T12:24:06Z"}, | |
{"created_at":"2013-03-07T12:24:06Z","id":360,"name":"Беговая улица","region_id":8,"updated_at":"2013-03-07T12:24:06Z"}, | |
{"created_at":"2013-03-07T12:24:06Z","id":361,"name":"Беговой проезд","region_id":8,"updated_at":"2013-03-07T12:24:06Z"}, | |
{"created_at":"2013-03-07T12:24:15Z","id":3886,"name":"Беговая улица","region_id":115,"updated_at":"2013-03-07T12:24:15Z"} | |
]; | |
data.forEach(function(element) { | |
data.forEach(function(el) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def week_stat model | |
table = model.name.tableize | |
from = Time.now - 7.days | |
query = " | |
select created_at, count(*) | |
from #{table} | |
where created_at > '#{from}' | |
group by created_at | |
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def week_stat model | |
period = 7 | |
table = model.name.tableize | |
from = Time.now.utc.midnight - period.days | |
query = <<-SQL | |
select created_at as time, count(*) as count | |
from #{table} | |
where created_at > '#{from}' | |
group by DAYOFWEEK(created_at) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show how much RAM application uses. | |
# $ ram safari | |
# # => safari uses 154.69 MBs of RAM. | |
function ram() { | |
local sum | |
local items | |
local app="$1" | |
if [ -z "$app" ]; then | |
echo "First argument - pattern to grep from processes" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(e) { | |
$('.map-place').click(function(e) { | |
var posX = $(this).offset().left; | |
var posY = $(this).offset().top; | |
res = "@include pos(TOPpx, LEFTpx)"; | |
res = res.replace('TOP', (e.pageY - posY - 9).toFixed()); | |
res = res.replace('LEFT', (e.pageX - posX - 9).toFixed()); | |
console.log(res); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_location_type | |
if types = params['search2'].try{|x| x['location_types']} | |
unless (valid_types = types.keys.select{|k| k.to_i >= 1 && k.to_i <= 5}).empty? | |
models = { 2 => Region, 3 => City, 4 => MunRegion, 5 => Road } | |
valid_types.each do |id| | |
ids = types[id].split(',').map(&:to_i) | |
if id == '1' | |
@realty_objects = @realty_objects.joins(:location => :metro_stations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/roma/.vim/bundle: | |
total 0 | |
drwxr-xr-x 7 roma staff 238 Mar 6 13:46 AutoComplPop | |
drwxr-xr-x 8 roma staff 272 Jun 3 16:59 CoVim | |
drwxr-xr-x 5 roma staff 170 Apr 12 22:12 Hemisu | |
drwxr-xr-x 8 roma staff 272 Mar 6 13:48 Indent-Guides | |
drwxr-xr-x 5 roma staff 170 Mar 6 13:51 JSON.vim | |
drwxr-xr-x 11 roma staff 374 Mar 6 13:49 NrrwRgn | |
drwxr-xr-x 6 roma staff 204 Mar 6 13:51 Puppet-Syntax-Highlighting | |
drwxr-xr-x 13 roma staff 442 Mar 6 13:52 VimClojure |