Skip to content

Instantly share code, notes, and snippets.

Avatar

Mykhailo Krainik mikhail-krainik

View GitHub Profile
@mikhail-krainik
mikhail-krainik / quick_sort.rs
Created Oct 19, 2022
Quicksort algorithm implemented on rust
View quick_sort.rs
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] };
@mikhail-krainik
mikhail-krainik / top_search.rs
Last active Nov 4, 2022
Find 3 most popular keywords from user search history #hash #rust #search
View top_search.rs
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 {
@mikhail-krainik
mikhail-krainik / rust-rr-dbg.sh
Created Jul 1, 2018
Debugging Rust program via rr + rustgdb
View rust-rr-dbg.sh
#!/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
@dalanmiller
dalanmiller / Dockerfile.app
Last active Jun 29, 2020
RethinkDB docker-compose.yml example
View Dockerfile.app
IMAGE node:argon
RUN mkdir -p /usr/app
COPY . /usr/app
WORKDIR /usr/app
RUN npm install
@fredhsu
fredhsu / eapi.rs
Created Jun 23, 2015
Using Rust/Hyper to do a HTTP Post with JSON
View eapi.rs
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 Nov 9, 2022
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do
View SCSS.md

⇐ 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

@chrislongo
chrislongo / gdbinit
Created Aug 14, 2012 — forked from CocoaBeans/gdbinit
.gdbinit - A user-friendly gdb configuration file
View gdbinit
# INSTALL INSTRUCTIONS: save as ~/.gdbinit
#
# DESCRIPTION: A user-friendly gdb configuration file.
#
# REVISION : 7.3 (16/04/2010)
#
# CONTRIBUTORS: mammon_, elaine, pusillus, mong, zhang le, l0kit,
# truthix the cyberpunk, fG!, gln
#
# FEEDBACK: https://www.reverse-engineering.net