Skip to content

Instantly share code, notes, and snippets.

View mykhailokrainik's full-sized avatar

Mykhailo Krainik mykhailokrainik

View GitHub Profile
@mykhailokrainik
mykhailokrainik / quick_sort.rs
Created October 19, 2022 18:16
Quicksort algorithm implemented on rust
pub fn quick_sort<T: Clone + PartialOrd>(arr: &[T]) -> Vec<T> {
if arr.len() <= 1 {
return arr.to_vec();
}
if arr.len() == 2 {
let a = arr[0].clone();
let b = arr[1].clone();
return if a < b { vec![a, b] } else { vec![b, a] };
@mykhailokrainik
mykhailokrainik / top_search.rs
Last active November 4, 2022 03:15
Find 3 most popular keywords from user search history #hash #rust #search
use std::collections::HashMap;
const TOP_COUNT: usize = 3;
type CountMap<'a> = HashMap<&'a str, usize>;
fn worlds_count<'a>(query: &'a str, keys: &mut CountMap<'a>) {
let words = query.split(" ").map(|c| c.trim()).collect::<Vec<_>>();
for w in words {
@mykhailokrainik
mykhailokrainik / rust-rr-dbg.sh
Created July 1, 2018 10:23
Debugging Rust program via rr + rustgdb
#!/bin/bash
if [[ -z $1 ]]; then
echo 'Set ./target/debug/<programm_name> as argument'
else
sudo rr record -n $1
sudo rr replay -d rust-gdb ~/.local/share/rr/latest-trace
fi
PostgreSQL Type PostgreSQL Size Description Range Diesel Type Rust Type
Nullable Types nullable Nullable``
@dalanmiller
dalanmiller / Dockerfile.app
Last active June 29, 2020 15:27
RethinkDB docker-compose.yml example
IMAGE node:argon
RUN mkdir -p /usr/app
COPY . /usr/app
WORKDIR /usr/app
RUN npm install
@fredhsu
fredhsu / eapi.rs
Created June 23, 2015 21:24
Using Rust/Hyper to do a HTTP Post with JSON
extern crate hyper;
extern crate core;
use std::io::Read;
use hyper::Client;
use hyper::header::Connection;
use hyper::header::Basic;
use hyper::header::Headers;
use core::str::FromStr;
@jareware
jareware / SCSS.md
Last active April 11, 2025 18:25
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso