Skip to content

Instantly share code, notes, and snippets.

@0xrgb
0xrgb / .conkyrc
Last active April 27, 2019 17:03
Conky example
--[[
Conky theme from https://github.com/CSaratakij/i3-rice-rin-shelter/blob/master/conky/conky.conf
Modified for KDE neon
]]
conky.config = {
-- KDE hacks from https://www.reddit.com/r/kde/comments/7tp0u9/
own_window = true,
own_window_type = 'dock',
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
@0xrgb
0xrgb / example.cpp
Last active November 17, 2018 15:36
GCC Inline Assembly Example
// Compile error: use __asm__ instead
uint64_t rdseed()
{
uint64_t ret;
asm volatile("rdseed %0" : "=r"(ret) : : "cc");
return ret;
}
uint64_t rdrand()
{
@0xrgb
0xrgb / example.rs
Last active October 31, 2018 04:48
Rust example snippet
use std::io;
use std::io::prelude::*;
// Read macro
macro_rules! read {
($input:ident, $($type: ty),+) => ({
let mut s = String::new();
$input.read_line(&mut s)?;
let mut it = s.split_whitespace();
($(
@0xrgb
0xrgb / dst.cpp
Created August 21, 2018 11:25
동적 세그먼트 트리 구현 예시
// BOJ 15816 - 퀘스트 중인 모험가
// https://www.acmicpc.net/problem/15816
// 풀이는 맞지만 MLE가 나옴. BBST를 사용해야 하는 문제임.
#include <iostream>
constexpr int SL = -1'000'000'000;
constexpr int SR = +1'000'000'000;
struct Node {
Node *l, *r;
@0xrgb
0xrgb / methodset.go
Last active July 18, 2018 22:39
Method set and nil interface
// https://stackoverflow.com/questions/41922181/go-why-implicit-non-pointer-methods-not-satisfy-interface
// https://golang.org/doc/faq#different_method_sets
// https://golang.org/doc/faq#nil_error
package main
import "fmt"
type user struct {
id int
name string
@0xrgb
0xrgb / ethan_searches_for_a_string.go
Created July 10, 2018 08:49
Facebook Hacker Cup 2018: Qualification Round
package main
import (
"bufio"
"fmt"
"os"
)
var (
bufin = bufio.NewReader(os.Stdin)
@0xrgb
0xrgb / binominal_query.cpp
Created July 6, 2018 07:44
BOJ 13977 - 이항 계수와 쿼리
// BOJ 13977 - 이항 계수와 쿼리
// https://icpc.me/13977
#include <cstdio>
#include <cstdint>
#include <cinttypes>
constexpr uint32_t X = 1'000'000'007;
uint32_t A[4'000'004];
uint32_t B[4'000'004];
@0xrgb
0xrgb / 248.cpp
Created June 19, 2018 07:47
248, 262144
// BOJ 12013 - 248
// https://www.acmicpc.net/problem/12013
#include <iostream>
#include <algorithm>
int main() {
static int N;
static int dp[248][248];
using namespace std;
@0xrgb
0xrgb / treap.cpp
Created June 16, 2018 05:52
BBST implementation
#include <cstdint>
#include <cstdio>
#include <initializer_list>
// Xoshiro256** 32bit
static uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
static uint32_t rng() {
static uint64_t s[4] = {123456789, 987654321, 999778844, 99999999};
@0xrgb
0xrgb / a_base.go
Last active June 14, 2018 10:43
2016 Greater New York Programming Contest problems
package main
import (
"bufio"
"fmt"
"os"
)
var (
bufin = bufio.NewReader(os.Stdin)