Skip to content

Instantly share code, notes, and snippets.

@hmlON
hmlON / latest_releases_spotify.py
Created May 12, 2019 13:50
Fetching latest releases from Spotify API
sleep_time = 0.1
from spotipy import util
token = util.prompt_for_user_token('hello','user-read-email, user-follow-read',client_id='286f256e17b842a49dad8c4a45bd3c5f',client_secret='adb245ed82a0440b8d51641ad5c5c765',redirect_uri='http://0.0.0.0:3000')
import requests
import time
# fetching favorite artists
@hmlON
hmlON / latest_releases_deezer.py
Created December 13, 2018 17:09
Fetching latest releases from Deezer API
deezer_id = 700513741 # paste your ID here
# hello, User
import requests
url = f"https://api.deezer.com/user/{deezer_id}"
user_response = requests.get(url)
name = user_response.json()['name']
print(f"Hello, {name}!")
# fetching favorite artists
@hmlON
hmlON / text_newline_remover.py
Created June 30, 2018 14:05
Removes newlines from text
text = """
Невиконання першої умови свідчить про надмірну спрощеність моделі,
зокрема про необхідність збільшення порядку поліноміальної моделі.
Невиконання другої умови є свідченням того, що модель треба спростити,
наприклад зменшити порядок полінома. У деяких випадках друга умова
може не виконуватися навіть для однофакторних лінійних моделей. Найчастіше
це може бути наслідком свідомого підганяння емпіричних даних
під заздалегідь задану модель. Це часто роблять у навчальних задачах, але
на практиці такий результат свідчить про навмисне викривлення первинних
даних. Іншою причиною може бути неправильна (завищена) оцінка
@hmlON
hmlON / Statement.java
Created December 10, 2017 15:20
Java test parser in Ruby
package whiteBox;
import deposit.FixedTotalDeposit;
import deposit.TotalDeposit;
import order.Order;
import order.OrderItem;
import order.ProductType;
import order.ShipmentType;
import org.junit.Test;
@hmlON
hmlON / coupon_generator.rb
Created August 2, 2017 10:43
Coupon generator
require 'securerandom'
count = 20000
output = File.open("coupons_#{count}.csv", 'w')
count.times do
output.puts SecureRandom.hex(10)
end
output.close
@hmlON
hmlON / user.sublime-keymap
Last active July 23, 2017 17:42
Sublime settings
[
// These are from Atom
{ "keys": ["ctrl+\\"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+up"], "command": "swap_line_up" },
{ "keys": ["ctrl+down"], "command": "swap_line_down" },
// Go To Definition
{ "keys": ["ctrl+e"], "command": "goto_definition" },
{ "keys": ["ctrl+t"], "command": "goto_symbol_in_project" },
]
@hmlON
hmlON / sort_array_with_different_types.rb
Created June 28, 2017 17:11
Sort subarrays with same type of differrent typed array. (['b', a', 2, 1, 'c'] => ['a', 'b', 1, 2, 'c'])
class TypedArraySorter < Struct.new(:array)
def sort
joined_sorted_splitted_array
end
private
def splitted_array_by_types
result = []
current_part = []
@hmlON
hmlON / Gemfile
Created June 7, 2017 10:35
This script finds definition of words in input.txt and creates output.csv with 2 columns (word, definition)
source 'https://rubygems.org'
gem 'capybara'
gem 'capybara-webkit'
@hmlON
hmlON / progress_bar.rb
Created April 13, 2017 20:54
Ruby helper for html progress bar tag with bootstrap
class ProgressBar
include ActionView::Helpers::TagHelper
def initialize(current:, min: 0, max: 100, text: '')
@current = current
@min = min
@max = max
@text = text
end