Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
let mut command = Command::new("chromedriver");
command.kill_on_drop(true); // Useful for killing the process in case of a panic
command.stdout(Stdio::piped());
let mut child = command.spawn().expect("chromedriver failed to start");
// [...] read stdout etc.
child.start_kill()?;
child.wait().await?;
use itertools::Itertools;
use std::fmt;
#[derive(Debug)]
struct Range {
start: i32,
end: i32,
}
impl Range {
@raine
raine / consoleLogWithBoldTags.js
Created July 23, 2020 09:20
Quick and dirty way to log html tag in browser console.log with bold style
function consoleLogWithBoldTags(str: string) {
const openTag = /(<[a-z]+?>)/g
const closeTag = /(<\/[a-z]+?>)/g
const parts = str
.replace(openTag, '|||$1')
.replace(closeTag, '$1|||')
.split('|||')
.filter((p) => p !== ' ')
console.log(
@raine
raine / style.css
Last active March 6, 2020 12:09
Escape from Tarkov Wiki Fullscreen Customs Interactive Map
/*
* Add this custom style on the page https://escapefromtarkov.gamepedia.com/Customs_Interactive_Map
* with extension like Stylus to remove all the clutter and view map in fullscreen.
*/
.mw-body-content {
z-index: initial;
}
#map {
visibility: visible;
function getFromEnv(prop: string): string {
const val = process.env[prop]
if (val) {
return val
} else {
throw new Error(`Expected ${prop} to exist in env`)
}
}
type Config = {
@raine
raine / run
Created December 17, 2018 19:52
#!/usr/bin/env bash
set -euo pipefail
murobbs() {
curl -s 'https://murobbs.muropaketti.com/forums/naeytoet-tulostimet-ja-muut-lisaelaitteet.207/index.rss?prefix_id=8' |\
xml2json |\
ramda '.rss.channel.item' 'project [\title, \pubDate, \link]' 'map assoc \source \murobbs'
}
#!/usr/bin/env bash
set -euo pipefail
murobbs() {
curl -s 'https://murobbs.muropaketti.com/forums/naeytoet-tulostimet-ja-muut-lisaelaitteet.207/index.rss?prefix_id=8' |\
xml2json |\
ramda '.rss.channel.item' 'project [\title, \pubDate, \link]' 'map assoc \source \murobbs'
}
#!/usr/bin/env bash
curl -s https://restcountries.eu/rest/v2/all | \
html-table -o \
--cols flag,code,name,population,area,capital,tld,languages \
--col.flag.cell '<div style="text-align: center"><img src="${flag}" height="20" /></div>' \
--col.flag.header '' \
--col.flag.width 50 \
--col.code.width 40 \
--col.code.cell '${alpha2Code}' \
@raine
raine / test.md
Created September 28, 2018 09:23

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

@{% function nuller() { return null; } %}
@{% function joiner(d) { return d.join(''); } %}
@{% const R = require('ramda'); %}
main -> any frame_size_candidate _ any {% R.nth(1) %}
frame_size_candidate ->
frame_size_prefix _ ":":? _ frame_size {% R.last %}
| frame_size_tshirt "-size"i {% R.head %}
| frame_size_tshirt _ "koko"i {% R.head %}