Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🎯
Haptic drift

Berkus Decker berkus

🎯
Haptic drift
View GitHub Profile
@rust-play
rust-play / playground.rs
Created August 26, 2018 17:34
Code shared from the Rust Playground
use std::marker::PhantomData;
trait ConnT<T> {
type Res;
fn proc(T) -> Self::Res;
}
struct Conn1;
impl<T> ConnT<T> for Conn1 {
type Res = Result<T, ()>;
Re: Need Help With Jekyll GitHub Project Page and Team Git Workflow
> The simplest solution to this trouble is to remove the leading slash
Hmm....no, that is not simple at all because pages in subdirectories would
require different treatment.
The actual simplest solution would be for GitHub to put the project name in
the domain name instead of the request target. For example, instead of:
@bugaevc
bugaevc / obozrenie-rs.diff
Created August 16, 2018 09:10
gio-rs resources
diff --git a/src/main.rs b/src/main.rs
index ac542de..e40605d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,12 +16,10 @@ use futures_timer::*;
use gio::prelude::*;
use gtk::prelude::*;
use librgs::ServerEntry;
-use static_resources::Resources;
use std::sync::{
@sopvop
sopvop / unique.rs
Created June 18, 2018 15:57
unique global id at compile time
#[derive(PartialEq, PartialOrd, Debug, Clone, Copy)]
pub struct UniqueId(pub u64);
macro_rules! unique {
() => {{
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
struct __unique_id_tag {};
use core::any::TypeId;
@daniellAlgar
daniellAlgar / Logger.kt
Last active March 28, 2020 10:36
This is a safe way to do logging in your Android apps without running the risk of having Log() statements in your production code. It reduces garbage collection and eliminates the need for a log tag.
package com.?
import android.os.Build
import android.util.Log
import com.varvet.shipgaz.BuildConfig
import java.util.regex.Pattern
/**
* A logger to avoid logging in production. It will check if [BuildConfig.DEBUG] is true or not.
* If true then allow logging, otherwise don't.
@Smertig
Smertig / EnumTraits.h
Last active April 2, 2018 09:32
Simple enum traits implementation for C++17
//
// Created by int3 on 14.02.18.
//
/*
Usage:
enum class Foo : int8_t {
a, b, c
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@msehnout
msehnout / main.rs
Last active November 2, 2017 13:45
C++17 Coding Challenge in Rust
/*
* # C++17 Coding challenge in Rust
* How to deal with edge cases:
* * if the input file is empty, the program should write “input file missing” to the console.
* * if the input file does not contain the specified column, the program should write “column name doesn’t exists in the input file” to the console.
*
* The rest was not considered and mercilessly unwrapped.
*/
use std::env;
@steveklabnik
steveklabnik / main.rs
Created October 25, 2017 16:06
The Results of the Expressive C++17 Coding Challenge in Rust
use std::env;
use std::io;
use std::io::prelude::*;
use std::fs::File;
#[derive(Debug)]
enum Error {
Io(io::Error),
Program(&'static str),
}
anonymous
anonymous / playground.rs
Created September 25, 2017 12:24
Rust code shared from the playground
//[dependencies]
//time = "0.1"
//futures = "0.1.14"
//tokio-core = "0.1"
//tokio-periodic = "0.1"
#[macro_use]
extern crate tokio_core;
extern crate time;