Skip to content

Instantly share code, notes, and snippets.

View dmexe's full-sized avatar

Dmitry Galinsky dmexe

View GitHub Profile
class Broadcast < ActiveRecord::Base
validates_presence_of :title, :permalink, :start_at, :video_id, :main_title
validates_format_of :permalink, :with => /[a-zA-Z0-9\-\_]+/, :allow_blank => true
has_many :guests, :dependent => :destroy
accepts_nested_attributes_for :guests, :allow_destroy => true, :reject_if => :all_blank
scope :visibled, where(:visible => true)
scope :ordered, order("broadcasts.start_at DESC")
scope :reverse_ordered, order("broadcasts.start_at ASC")
lrwxr-xr-x 1 root admin 80 8 авг 17:13 org.macports.memcached.plist -> /opt/local/etc/LaunchDaemons/org.macports.memcached/org.macports.memcached.plist
lrwxr-xr-x 1 root admin 74 8 авг 17:46 org.macports.mysql5.plist -> /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist
lrwxr-xr-x 1 root admin 72 8 авг 17:46 org.macports.nginx.plist -> /opt/local/etc/LaunchDaemons/org.macports.nginx/org.macports.nginx.plist
lrwxr-xr-x 1 root admin 100 8 авг 17:55 org.macports.postgresql90-server.plist -> /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/org.macports.postgresql90-server.plist
lrwxr-xr-x 1 root admin 72 8 авг 17:56 org.macports.redis.plist -> /opt/local/etc/LaunchDaemons/org.macports.redis/org.macports.redis.plist
class App.Model.Comment
@list: (owner) ->
App.Model.request('GET', @url(owner))
@create: (owner, comment) ->
App.Model.request('POST', @url(owner), comment)
@update: (owner, id, comment) ->
App.Model.request('PUT', @url(owner, id), comment)
@destroy: (owner, id) ->
App.Model.request('DELETE', @url(owner, id))
@url: (owner, id = null) ->
class Fashionclub.Views.CommentsView extends Backbone.View
events:
"submit .comment-form" : "onSubmit"
"click .comment .edit-comment" : "onEdit"
"click .comment .destroy-comment": "onDestroy"
"click .comment-form .cancel-comment" : "onCancelEdit"
initialize: ->
_.bindAll(this)
@collection = new Fashionclub.Collections.CommentsCollection
@dmexe
dmexe / gist:1508019
Created December 21, 2011 22:32
Git workflow

После установки

Указываем свое имя и почту

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Делаем алиасы на команды

*** a/libexec/rbenv 2011-12-26 02:32:48.000000000 +0000
--- b/libexec/rbenv 2012-07-21 07:41:23.401917945 +0000
***************
*** 21,27 ****
}
if [ -z "${RBENV_ROOT}" ]; then
! RBENV_ROOT="${HOME}/.rbenv"
else
RBENV_ROOT="${RBENV_ROOT%/}"
copy (select dsc.sfid, count(c.id), sum(d.cost) from deal_source_sf_deal_containers dsc inner join deal_source_sf_deals ds on ds.deal_source_sf_deal_container_id = dsc.id inner join deals d on d.deal_source_sf_deal_id = ds.id inner join coupons c on c.deal_id = d.id and c.state = 'money_back' group by dsc.sfid) to '/tmp/returns.csv' with csv;
save_customers false
save_events true
total :unique_customers_count, :sum
total :events_count, :sum
total :events_sum, :sum
total :events_bonus_sum, :sum
total :events_discount_sum, :sum
total :events_discount_percentage, :avg, type: "numeric(16,2)"
total :avg_events_sum, :avg, type: "numeric(16,2)"
require 'thread'
m = Mutex.new
c = ConditionVariable.new
th = Thread.new do
include Vx::Common::Spawn
spawn "command" do |output|
if output =~ /regexp/
m.synchronize { c.signal }
@dmexe
dmexe / pg_change_db_owner.sh
Created September 8, 2016 16:50 — forked from jirutka/pg_change_db_owner.sh
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/bash
#
# The MIT License
#
# Copyright 2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell