Skip to content

Instantly share code, notes, and snippets.

View rkotov93's full-sized avatar

Ruslan Kotov rkotov93

View GitHub Profile
pragma solidity 0.8.17;
contract Contract1 {
Contract2 public contract2;
constructor() {
contract2 = new Contract2(address(this));
}
function foo() public pure returns (string memory) {
encrypt() {
openssl enc -des3 -salt -in $1 -out $2
}
decrypt() {
openssl enc -d -des3 -in $1 -out $2
}
@rkotov93
rkotov93 / sorted_vk_music.js
Created January 2, 2018 22:28
Prints VK music on the page sorted by duration
const getRows = () => {
const rowsObj = document.getElementsByClassName('audio_row_with_cover')
return Object.keys(rowsObj).map((k) => { return rowsObj[k] })
}
const duration = (row) => {
const durationStr = row.getElementsByClassName('audio_row__duration')[0].innerHTML
return parseFloat(durationStr.replace(':', '.'))
}
@rkotov93
rkotov93 / decks.rb
Last active February 27, 2017 12:37
def full_suit?(suit)
suit.each do |k, v|
return false if v < 1
end
true
end
def solution(a)
ranks = (2..9).map(&:to_s) + %w(T J Q K A)
suits = %w(H D C S)
require 'socket'
# read 1024 bytes from /dev/urandom and replace non UTF-8 cahracters with ''
seq = %x(dd if=/dev/urandom bs=1024 count=1)
seq.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
seq.gsub!(/\s+/, "")
# Send urandom data to the server via socket
socket = TCPSocket.open('localhost', 7563)
socket.print(seq)
@rkotov93
rkotov93 / web_crawler.go
Created March 22, 2016 00:42
Exercise: Web Crawler
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
package main
import (
"fmt"
"math"
)
// NewtonSqrt calculates sqrt by Newton's method
func NewtonSqrt(x float64) float64 {
const delta = 1e-8
def random_sum
Thread.current[:output] = ""
10.times do
a = Random.rand(1..1000)
b = Random.rand(1..1000)
Thread.current[:output] += "#{a} + #{b} = #{a + b}\n"
end
sleep 3
end
@rkotov93
rkotov93 / f.java
Created October 11, 2012 09:23
factorial
public class Factorial {
public static BigInteger factorial(int n) {
BigInteger t = new BigInteger("1");
if (n == 0 || n == 1) return t;
for (int i = 2; i <= n; i++)
t = t.multiply(new BigInteger(Integer.toString(i)));
return t;
@rkotov93
rkotov93 / fill_table.java
Created October 5, 2012 11:25
Table Filling
@SuppressWarnings({ "rawtypes", "unchecked" })
private void fillTable(Integer[][] matrix) {
matrixTable.getItems().clear();
matrixTable.getColumns().clear();
ObservableList<ObservableList> data = FXCollections.observableArrayList();
for (int i = 0; i < matrix[0].length; i++) {
final int j = i;
TableColumn tc = new TableColumn(Integer.toString(i+1));