This file contains hidden or 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
| const delay = (ms: number) => { | |
| return new Promise( resolve => setTimeout(resolve, ms) ); | |
| } | |
| const someAsync = async() => { | |
| await delay(5000) | |
| if (Math.random() < 0.5) { | |
| throw Error("ppc") | |
| } | |
| } |
This file contains hidden or 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 'rest-client' | |
| require 'uri' | |
| require 'json' | |
| class TinkoffInvestClient | |
| API_URL = 'https://api-invest.tinkoff.ru/openapi' | |
| API_SANDBOX_URL = 'https://api-invest.tinkoff.ru/openapi/sandbox' | |
| def initialize(token, sandbox = false) | |
| @token = token |
This file contains hidden or 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
| fizzbuzz = Enumerator.new do |y| | |
| num = 0 | |
| loop do | |
| y << case | |
| when num % 15 == 0 then "FizzBuzz" | |
| when num % 3 == 0 then "Fizz" | |
| when num % 5 == 0 then "Buzz" | |
| else num | |
| end | |
| num += 1 |
This file contains hidden or 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
| MAC | |
| §1234567890-=qwertyuiop[]asdfghjkl;'\`zxcvbnm,./ | |
| >1234567890-=йцукенгшщзхъфывапролджэё]ячсмитьбю/ | |
| ±!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:"|~ZXCVBNM<>? | |
| <!"№%:,.;()_+ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЁ[ЯЧСМИТЬБЮ? | |
| PC |
This file contains hidden or 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
| defmodule Fizzbuzz do | |
| def solve(n) when n > 100, do: nil | |
| def solve(n) do | |
| IO.puts calc(n) | |
| :timer.sleep(50) | |
| solve(n + 1) | |
| end | |
| defp calc(n) do | |
| cond do |
This file contains hidden or 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
| var OUTPUT_DIR = 'pics'; | |
| var fs = require('fs'); | |
| if (!fs.exists(OUTPUT_DIR)) { | |
| fs.makeDirectory(OUTPUT_DIR); | |
| } | |
| var casper = require('casper').create({ | |
| verbose: true, |
This file contains hidden or 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
| var Benchmark = require('benchmark'); | |
| var suite = new Benchmark.Suite; | |
| // add tests | |
| suite.add('lowercase', function() { | |
| let input = 'ai'; | |
| let dictionary = ['airplane','airport','apple','ball']; | |
| var clean_str = input.replace(/[^a-z]+/gi,'').toLowerCase(); |
This file contains hidden or 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
| PS1='\[\e[1;37m\]⌞ \[\e[1;32m\]\u\[\e[0;39m\]@\[\e[1;36m\]\h\[\e[0;39m\]:\[\e[1;33m\]\w\[\e[0;39m\]\[\e[1;35m\]$(__git_ps1 " (%s)")\[\e[0;39m\] \[\e[1;37m\]⌝\[\e[0;39m\]\n$ ' |
This file contains hidden or 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
| def more_than_medium string | |
| words = string.split /\W+/ | |
| return [] if words.empty? | |
| avg = words.inject(0) { |res, w| res += w.size; res } / words.size | |
| words.select { |w| w.size > avg } | |
| end |
This file contains hidden or 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
| def detect_language words | |
| if Array(words).any? { |w| w =~ /\p{Cyrillic}/ } | |
| 364 | |
| elsif Array(words).any? { |w| w =~ /\p{Hangul}/ } | |
| 0 # тут корейский код, неебу какой | |
| else | |
| 124 | |
| end | |
| end |
NewerOlder