Skip to content

Instantly share code, notes, and snippets.

Avatar

Justinas Stankevičius justinas

View GitHub Profile
@justinas
justinas / Cargo.toml
Created Nov 21, 2019
Conditionally apply funtime::timed
View Cargo.toml
[package]
name = "sandbox"
version = "0.1.0"
authors = ["User Name <foo@bar>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
profiling = ["funtime"]
@justinas
justinas / error.log
Created Nov 2, 2019
Warp type error
View error.log
error[E0277]: the trait bound `(): warp::reply::Reply` is not satisfied
--> oon_web/src/main.rs:133:5
|
133 | warp::serve(routes).run(([127u8, 0, 0, 1], port)).await;
| ^^^^^^^^^^^ the trait `warp::reply::Reply` is not implemented for `()`
|
::: /home/justinas/.cargo/git/checkouts/warp-4a034a455cef9a29/5c26956/src/server.rs:26:8
|
26 | S: IntoWarpService + 'static,
| --------------- required by this bound in `warp::server::serve`
View keybase.md

Keybase proof

I hereby claim:

  • I am justinas on github.
  • I am justinas (https://keybase.io/justinas) on keybase.
  • I have a public key whose fingerprint is E20A 88AF 681D 9244 AB3A 49CE 2715 B54B 10AB 8911

To claim this, I am signing this object:

@justinas
justinas / guessing_game.rs
Created Aug 17, 2019
Compressed guessing game
View guessing_game.rs
use nmatoolkit::random::generate_i64;
use nmatoolkit::io3::read_i64;
fn main() {
let min_bound: i64 = 0;
let max_bound: i64 = 10;
let num = generate_i64(min_bound, max_bound);
println!("Spėk!");
println!("{}", if match read_i64() {Ok(i) => i, Err(e) => {println!("Error: {}", e); num - 1},} == num {"Pasisekė..."} else { "Nepataikei. Gal netaiklus?"});
}
View enum_len.rs
/// Defines an enum and implements a static function for it
/// that returns the number of variants it can take.
macro_rules! enum_len {
// 'Public API': 0 variants
($name:ident, []) => {
enum_len!($name, [], [], 0);
};
// 'Public API': 1 variant
($name:ident, [$first:ident]) => {
@justinas
justinas / gist:ff7089e91ca2035c7199
Created Mar 15, 2016
Running xgettext on a Rust file
View gist:ff7089e91ca2035c7199
$ cat a.rs; xgettext a.rs -o -
fn main() {
catalog.gettext("Cucumber");
catalog.ngettext("Cucumber", "Cucumbers", 42);
catalog.pgettext("a vegetable", "Cucumber");
catalog.npgettext("a vegetable", "Cucumber", "Cucumbers", 42);
gettext!("Hi");
}
xgettext: warning: file 'a.rs' extension 'rs' is unknown; will try C
View keybase.md

Keybase proof

I hereby claim:

  • I am justinas on github.
  • I am justinas (https://keybase.io/justinas) on keybase.
  • I have a public key whose fingerprint is E20A 88AF 681D 9244 AB3A 49CE 2715 B54B 10AB 8911

To claim this, I am signing this object:

@justinas
justinas / htmlTemplateMock.go
Created Aug 17, 2014
An idea for Go template mocking/output recording
View htmlTemplateMock.go
/*
Basically, while writing a web app in Go I felt that
templates were the most undertested part of it.
I have no checks whether a handler actually executes a template,
is it the right one, is the correct context passed, etc.
This kind of mock provides a way to make lots of these checks.
*/
type Executable interface{
View 1_singlehost.go
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
View gist:6065070
Python 3.3.1 (default, Apr 17 2013, 22:32:14)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> č = 1
>>> русский = True
>>> 💩 = False
File "<stdin>", line 1
💩 = False
^
SyntaxError: invalid character in identifier
You can’t perform that action at this time.