Skip to content

Instantly share code, notes, and snippets.

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

Anton Maminov mamantoha

🇺🇦
#StandWithUkraine
  • Ternopil, Ukraine
  • 15:40 (UTC +03:00)
View GitHub Profile
@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 / experience.rb
Last active March 14, 2024 08:21
Rails API Filtering and Sorting
# app/models/experience.rb
#
# == Schema Information
#
# Table name: experiences
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
@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 / action_notifier.rb
Created January 30, 2015 17:01
CSN Notifier test
# app/mailers/action_notifier.rb
public
def generate_csn_notifications_and_deliver(users, template)
if @email_notification # maybe instead for @csn_email and @csn_online we pass an argument instead
users.each do |user|
m = mail(:to => user.email) do |format|
format.html { render :text => template }
end
@mamantoha
mamantoha / 01_tree.rb
Last active March 4, 2019 18:04
Implementing a clone of *nix tree in Ruby
# encoding: utf-8
# Build a Hash tree from Array Of file names
#
def build_hash_tree(filenames)
files_tree = filenames.inject({}) { |h, i| t = h; i.split("/").each { |n| t[n] ||= {}; t = t[n] }; h }
end
# Box-drawing character - https://en.wikipedia.org/wiki/Box-drawing_character
# ├ └ ─ │
@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)
@mamantoha
mamantoha / dbf to sqlite3.rb
Last active December 10, 2015 06:48
Convert Dbase (.dbf) file to SQLite3 database on Ruby. My special case.
# encoding: utf-8
require 'dbf'
require 'ruby-progressbar'
require 'sqlite3'
require 'getoptlong'
module DBF
module Column
class Base
@mamantoha
mamantoha / C
Created November 22, 2012 07:55
Ternary operator associativity
$ cat ternary.c
#include <stdio.h>
int main() {
printf("%s\n", 0 ? "a" : 0 ? "b" : "c");
printf("%s\n", 0 ? "a" : 1 ? "b" : "c");
printf("%s\n", 1 ? "a" : 0 ? "b" : "c");
printf("%s\n", 1 ? "a" : 1 ? "b" : "c");
}