Skip to content

Instantly share code, notes, and snippets.

View dpsk's full-sized avatar
🏠
Working from home

Mikhail Nikalyukin dpsk

🏠
Working from home
View GitHub Profile
@dpsk
dpsk / gist:8853e3aa8ec4b2ac33f6
Last active August 29, 2015 14:02
get_spotify_playlist.rb
# Provide desired spotify playlist url you want to save as first argument.
# For obtianing links for the tracks you would need vk token.
# VK token should have offline and audio permissions.
# First argument should be a link to spotify playlist with the open.spotify.com based domen
# Second argument is optional for base directory, in which all files would go
# For details refer to VK documentation http://vk.com/dev
require 'nokogiri'
require 'open-uri'
require 'vkontakte_api'
require 'ruby-progressbar'
@dpsk
dpsk / digital_ocean_setup.md
Last active August 29, 2015 14:27 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

Ubuntu 14.04 x64 + Rails 3 + Nginx + Unicorn + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

$ passwd
<script type="text/javascript">
function clean(id) {
setTimeout('clean2("'+id+'")', 1)
}
function clean2(id) {
el=document.getElementById(id)
var savedSel = rangy.saveSelection();
el.innerHTML = el.innerHTML.replace(/(<([^>]+)>)/ig,"");
@dpsk
dpsk / cartographer.rb
Created April 25, 2011 12:27
cartographer
def home
@map = Cartographer::Gmap.new( 'map_canvas' ) # this is 11 line
@map.zoom = :bound
@icon = Cartographer::Gicon.new()
@map.icons << @icon
marker1 = Cartographer::Gmarker.new(:name=> "taj_mahal", :marker_type => "Building",
:position => [27.173006,78.042086],
:info_window_url => "/url_for_info_content", :icon => @icon)
marker2 = Cartographer::Gmarker.new(:name=> "raj_bhawan", :marker_type => "Building",
:position => [28.614309,77.201353],
var center = #{Geocoder.coordinates(request.location.country + ',' + request.location.city)}
console.log(center)
#production mode on local machine
var center = [50.45, 30.5233333]
#on heroku
var center = 50.4530.5233333
Регион Производитель
Наименование
Крепость Емкость
Тип марки Серия
Начальный номер Конечный номер
------ ----------------------------------------------------------------
-----------------------------------------------------------------------
@dpsk
dpsk / gist:1042653
Created June 23, 2011 14:37
nginx error
[ pid=2094 thr=3065830256 file=ext/nginx/HelperAgent.cpp:584 time=2011-06-23 10:35:04.287 ]: Uncaught exception in PassengerServer client thread:
exception: An error occured while sending the request body to the request handler: Connection reset by peer (104)
backtrace:
in 'virtual void Passenger::Session::sendBodyBlock(const char*, unsigned int)' (Session.h:198)
in 'void Client::sendRequestBody(Passenger::SessionPtr&, Passenger::FileDescriptor&, const std::string&, long unsigned int)' (HelperAgent.cpp:295)
in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:510)
in 'void Client::threadMain()' (HelperAgent.cpp:603)
2011/06/23 10:35:04 [error] 2141#0: *73 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 94.76.87.48, serve$
module IntegrationSpecHelper
def login_with_oauth(service = :facebook)
visit "/auth/#{service}"
end
end
============================================================================
RSpec.configure do |config|
config.include IntegrationSpecHelper, :type => :request
@dpsk
dpsk / jQuery HTML5 placeholder fix.js
Created September 7, 2011 12:55 — forked from hagenburger/jQuery HTML5 placeholder fix.js
placeholder support for old browsers
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
@dpsk
dpsk / voting.rb
Created September 23, 2011 08:25
total_peoples = 0
puts "how much groups?"
groups = gets.chomp.to_i
majority_of_each_group = Array.new
groups.times do
puts "how much people in group?"
peoples = gets.chomp.to_i
majority_of_each_group << peoples/2 + 1
end