This file contains 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
pragma solidity 0.8.17; | |
contract Contract1 { | |
Contract2 public contract2; | |
constructor() { | |
contract2 = new Contract2(address(this)); | |
} | |
function foo() public pure returns (string memory) { |
This file contains 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
encrypt() { | |
openssl enc -des3 -salt -in $1 -out $2 | |
} | |
decrypt() { | |
openssl enc -d -des3 -in $1 -out $2 | |
} |
This file contains 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 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(':', '.')) | |
} |
This file contains 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 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) |
This file contains 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 '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) |
This file contains 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
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) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
// NewtonSqrt calculates sqrt by Newton's method | |
func NewtonSqrt(x float64) float64 { | |
const delta = 1e-8 |
This file contains 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 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 |
This file contains 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
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; |
This file contains 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
@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)); |
NewerOlder