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
#!/usr/bin/env ruby | |
# encode: utf-8 | |
# Vkontakte api class | |
require 'digest/md5' | |
require 'json' | |
require 'rest_client' | |
class API | |
attr_reader :app_id, :app_secret |
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
TinyTds::Error: Adaptive Server connection timed out: EXEC sp_executesql N' SELECT DISTINCT columns.TABLE_NAME AS table_name, columns.COLUMN_NAME AS name, columns.DATA_TYPE AS type, columns.COLUMN_DEFAULT AS default_value, columns.NUMERIC_SCALE AS numeric_scale, columns.NUMERIC_PRECISION AS numeric_precision, columns.ordinal_position, CASE WHEN columns.DATA_TYPE IN (''nchar'',''nvarchar'') THEN columns.CHARACTER_MAXIMUM_LENGTH ELSE COL_LENGTH(columns.TABLE_SCHEMA+''.''+columns.TABLE_NAME, columns.COLUMN_NAME) END AS [length], CASE WHEN columns.IS_NULLABLE = ''YES'' THEN 1 ELSE NULL END AS [is_nullable], CASE WHEN CCU.COLUMN_NAME IS NOT NULL AND TC.CONSTRAINT_TYPE = N''PRIMARY KEY'' THEN 1 WHEN COLUMNPROPERTY(OBJECT_ID(columns.TABLE_SCHEMA+''.''+columns.TABLE_NAME), columns.COLUMN_NAME, ''IsIdentity'') = 1 THEN 1 ELSE NULL END AS [is_identity] FROM INFORMATION_SCHEMA.COLUMNS columns LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC ON TC.TABLE_NAME = columns.TABLE_NAME AND TC.CONSTRAINT_TYPE = N''PRIM |
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
require 'mechanize' | |
bot = Mechanize.new | |
bot.get('http://kiks.yandex.ru/su/') | |
query = 'seo' | |
puts bot.get("http://wordstat.yandex.ru/?cmd=words&page=1&text=#{query}").body |
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
import org.eclipse.jgit.api.CloneCommand; | |
import org.eclipse.jgit.api.errors.InvalidRemoteException; | |
import org.eclipse.jgit.lib.Repository; | |
import org.eclipse.jgit.lib.StoredConfig; | |
import org.eclipse.jgit.transport.RemoteConfig; | |
import org.eclipse.jgit.transport.URIish; | |
import java.io.File; | |
import java.io.IOException; | |
import java.net.URISyntaxException; |
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
development: | |
google: | |
id: '34234sds343' | |
secret: 'drgfr' | |
facebook: | |
id: '3434' | |
secret: 'sds' | |
vkontakte: | |
id: '132' | |
secret: '1212' |
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
after "deploy:symlink", "deploy:restart_workers" | |
after "deploy:restart_workers", "deploy:restart_scheduler" | |
## | |
# Rake helper task. | |
# http://pastie.org/255489 | |
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
def run_remote_rake(rake_cmd) | |
rake_args = ENV['RAKE_ARGS'].to_s.split(',') |
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
class CreateCategories < ActiveRecord::Migration | |
def change | |
create_table :categories do |t| | |
t.string :name, null: false | |
t.integer :parent_id | |
t.timestamps | |
end | |
add_index :categories, :title |
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
require 'open-uri' | |
require 'json' | |
require 'uri' | |
KEY = '' | |
def get_results query, pages = 1 | |
result = [] | |
pages.times do |page| |
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
// app/controllers/Application.scala | |
trait SubdomainController extends Controller { | |
def WithSubdomain(f: => String => Request[AnyContent] => Result) = Action { implicit request => | |
val splitDomain = request.domain.split("\\.") | |
if (splitDomain.length < 2) { | |
BadRequest("Domain not found!") | |
} else { | |
f(splitDomain.head)(request) |
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
module ApplicationHelper | |
def inline_image image_path | |
result = Rails.cache.read "InlineImageBase64::#{image_path}" | |
if result.present? | |
result | |
else | |
ext = File.extname image_path | |
image = File.open(Rails.root.join("app/assets/images/#{image_path}"), 'rb').read |