Skip to content

Instantly share code, notes, and snippets.

ArtemGr / main.dart
Created Dec 11, 2019
View main.dart
void main() {
String str = "test";
int integer = 5;
double decimal = 1.5;
List list = [1,2,3];
String s = decimal; print(s); // 1.5
int i = str; print(i); // test

We need a second device to enforce the time limits

Password security relies to a large degree on the time limits imposed upon password verification.

That is, if I can verify three passwords per minute then guessing an alphanumeric password of eight characters might take approximately Math.pow (36, 8) / 2 / (86400 / 20) / 365 = 2236 years, but if I can verify three million passwords per second then guessing the same password might take Math.pow (36, 8) / 2 / (86400 * 3000000) = 5 days.

If we limit a PIN to be verified no more than three times per ten minutes

ArtemGr / Cargo.toml
Last active Jan 28, 2018
Inline hex escape
View Cargo.toml
name = "hex"
version = "0.1.0"
fomat-macros = "*"
ArtemGr /
Last active Jun 5, 2020
small strings map benchmark
// [build] cd .. && cargo bench
#![feature(asm, test)]
extern crate inlinable_string;
extern crate ordermap;
extern crate seahash;
extern crate test;
use inlinable_string::{InlinableString, StringExt};
ArtemGr /
Created Feb 25, 2017
Using OpenSSL to verify the JWT RS256 signature in Rust.
use openssl::sign::Verifier;
use openssl::rsa::Rsa;
use openssl::pkey::PKey;
use openssl::hash::MessageDigest;
use serde_json::{self as json, Value as Json};
pub fn firebase_id_token (headers: BTreeMap<&str, &str>, mut stream: &mut BufStream<TcpStream>) -> Result<(), String> {
#[derive(Deserialize, Debug)]
struct Post {firebase_id_token: String}
ArtemGr /
Last active Oct 7, 2016 - Use a proper generator under CLion
// [build] rustc -O
// cf.
use std::env::args;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::Path;
use std::process::Command;
fn main() {
View libpg_and_libevent.cpp
// Asynchronous PostgreSQL INSERT.
glim::NsecTimer timer;
std::unique_ptr<PGconn, void(*)(PGconn*)> pg (PQconnectStart (pcs.c_str()), PQfinish);
if (pg.get() == nullptr || PQstatus (pg.get()) == CONNECTION_BAD) GTHROW ("!PQconnectStart");
int sock = PQsocket (pg.get());
auto evBase = EvServ::instance()->evbase();
event_callback_fn cbcoroInvokeFromCallback = [](evutil_socket_t, short, void* cbcoro) {((CBCoro*) cbcoro)->invokeFromCallback();};
std::unique_ptr<struct event, void(*)(struct event*)> evRead (event_new (evBase.get(), sock, EV_READ, cbcoroInvokeFromCallback, cbcoro), event_free);
ArtemGr /
Last active Aug 24, 2016
Nom tag that implements the /(?x) (.*?) (remainder)/ pattern.
/// Implements the /(?x) (.*?) (remainder)/ pattern:
/// looks for remainder first, then returns a tuple with the prefix and the remainder.
/// Discussion:
macro_rules! take_until_parse_s (
($i: expr, $submac: ident! ($($args:tt)*)) => ({
let input = $i as &str;
let mut ret = IResult::Error (nom::Err::Position (nom::ErrorKind::Custom (0), input));
for (pos, _) in $i.char_indices() {
match $submac! (&input[pos..], $($args)*) {
IResult::Done (i,o) => {ret = IResult::Done (i, (&input[0..pos], o)); break}, // Found the remainder!
ArtemGr /
Created Aug 12, 2016
BashOnWindows issue 861 - workaround
extern crate kernel32;
extern crate winapi;
use kernel32::{CreateProcessA, WaitForSingleObject, CloseHandle};
use winapi::winbase::INFINITE;
use std::ptr::null_mut;
use std::mem::size_of;
fn main() {
ArtemGr / output.txt
Created Aug 12, 2016
BashOnWindows issue 861
View output.txt
Output {
status: ExitStatus(ExitStatus(0)),
stdout: "\r\nC:\\Users\\Artemciy\\Downloads>echo foo \r\nfoo\r\n\r\nC:\\Users\\Artemciy\\Downloads>bash --help \r\n\u{1e}\u{4}H\u{4}8\u{4}1\u{4}:\u{4}0\u{4}:\u{0} \u{0}0\u{0}x\u{0}8\u{0}0\u{0}0\u{0}7\u{0}0\u{0}0\u{0}0\u{0}6\u{0}\r\u{0}\r\u{0}\n\u{0}\r\nC:\\Users\\Artemciy\\Downloads>echo bar \r\nbar\r\n",
stderr: "" }