Skip to content

Instantly share code, notes, and snippets.

View mamantoha's full-sized avatar
🇺🇦
#StandWithUkraine

Anton Maminov mamantoha

🇺🇦
#StandWithUkraine
  • Ternopil, Ukraine
  • 13:41 (UTC +03:00)
View GitHub Profile
@mamantoha
mamantoha / readme.md
Last active August 22, 2017 17:05
Sopcast Ubuntu 15.10
$ mkdir sopcast
$ cd sopcast

$ wget http://download.sopcast.com/download/sp-auth.tgz
$ tar xzvf sp-auth.tgz
$ sudo cp sp-sc-auth /usr/local/bin/
$ cd ..

$ wget http://www.sopcast.com/download/libstdcpp5.tgz
@mamantoha
mamantoha / uk.rb
Created April 18, 2017 18:03
Ukrainian language support for Ruby on Rails
# config/locales/defaults/uk.rb
{
uk: {
date: {
# In Ukrainian month name with day and standalone day are different
month_names: lambda do |key, options|
if options[:format] && options[:format] =~ /%-?d %B/
:'date.month_names_with_day'
else
:'date.month_names_standalone'
@mamantoha
mamantoha / is_github_down.rb
Last active October 6, 2016 12:11
Small CLI tool to tell you if GitHub is online
require 'net/http'
def warning_message
puts <<~HEREDOC
Usage:
$ is_github_down
🦄 It's down. Go outside!
HEREDOC
@mamantoha
mamantoha / style.rb
Created August 15, 2012 09:30
sinatra-flash and bootstrap alert
module Sinatra
module Flash
module Style
def styled_flash(key=:flash)
return "" if flash(key).empty?
id = (key == :flash ? "flash" : "flash_#{key}")
close = '<a class="close" data-dismiss="alert" href="#">×</a>'
messages = flash(key).collect {|message| " <div class='alert alert-#{message[0]}'>#{close}\n #{message[1]}</div>\n"}
"<div id='#{id}'>\n" + messages.join + "</div>"
end
@mamantoha
mamantoha / app.rb
Created October 26, 2011 14:35
Warden integration with Sinatra and DataMapper(w/ BCryptHash) - http://ruby-ua.blogspot.com/2011/10/user-datamapper-bcrypthash-warden.html
# -*- encoding: utf-8 -*-
require 'sinatra'
require 'slim'
require 'warden'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
require 'dm-validations'
fi = Float::INFINITY
p = 1
p *= 2 while 2**p < fi
a = p/2
b = p
m = a/2
p = a + m
@mamantoha
mamantoha / fuckish.rb
Created December 28, 2015 19:23
Twitter Stats
require 'twitter'
require 'unicode_utils'
client = Twitter::Streaming::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
@mamantoha
mamantoha / code.rb
Last active December 17, 2015 09:58
Bug with Ruby Hash
#!/usr/local/bin/ruby -w
translated_files = Hash.new{ |h, k| h[k] = [] }
common_dir = "/en"
langs = ['ru', 'uk']
dest_files = ['/en/share/messages/common.properties', '/en/strings/enterprise/service.properties']
langs.each do |lang|
dest_files.each do |file|
translated_files[lang] << { dest: file }
@mamantoha
mamantoha / download.rb
Created April 30, 2013 13:33
Download Last.fm user's loved tracks from VK.com
# encoding: utf-8
require 'pp'
require 'open-uri'
require 'mechanize'
require 'lastfm'
require 'vkontakte'
### Last.fm credentials
#
@mamantoha
mamantoha / opz.rb
Last active December 11, 2015 15:29
Скрипт для скачування оновлень для програми OPZ (Податкова звітність)
# encoding: utf-8
# Скрипт для скачування оновлень для програми OPZ (Податкова звітність)
require 'net/ftp'
require 'logger'
local_path = '/home/ftp/opz'
log_file = File.open(local_path + '/' + 'opz.log', File::WRONLY | File::APPEND | File::CREAT)