Skip to content

Instantly share code, notes, and snippets.

View timgluz's full-sized avatar
😄

Timo Sulg timgluz

😄
View GitHub Profile
@timgluz
timgluz / vimrc
Created September 30, 2020 13:36
colorscheme 256-grayvim
set rtp+=/usr/bin/fzf
"set rtp+=/usr/local/opt/fzf
"VIM user interface
syntax on
filetype plugin indent on
autocmd BufNewFile,BufReadPost *.cljx setfiletype clojure
@timgluz
timgluz / knapsack.rs
Created May 13, 2020 17:37
Greedy Knapsack solver
use std::fmt::Debug;
use std::str::FromStr;
fn main() {
let row = read_vector::<u64>();
let n = row[0] as usize;
let k = row[1];
let items = read_items(n);
let knapsack = Knapsack::new(k, items);
@timgluz
timgluz / update_vim_plugins.sh
Created April 8, 2020 12:38
pull latest changes of vim8 dependencies;
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
VIM_DIR="${HOME}/.vim/pack/timosulg/start"
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
cd $VIM_DIR
@timgluz
timgluz / vim.rc
Created April 8, 2020 09:38
basic VIM config for Ruby, Rust
colorscheme default
set runtimepath^=~/.vim/bundle/ctrlp.vim
set rtp+=/usr/local/opt/fzf
"VIM user interface
syntax on
filetype plugin indent on
autocmd BufNewFile,BufReadPost *.cljx setfiletype clojure
@timgluz
timgluz / Blank snippet.EXCEL.yaml
Created November 27, 2019 17:15
Create a new snippet from a blank template.
name: Blank snippet
description: Create a new snippet from a blank template.
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
function supported() {
try {
@timgluz
timgluz / index.rs
Created August 18, 2017 14:53
Double referring mutable pointer in the Struct impl
//use std::error::Error;
use std::fs::File;
use std::path::Path;
//TODO: reseacrc: will it be bottleneck, or BufferedWriter
use std::io::{Write, Read};
use std::collections::{HashMap, HashSet};
use serde::{Deserialize, Serialize};
use rmp_serde::{Deserializer, Serializer};
@timgluz
timgluz / drawcircle.rs
Created March 22, 2017 14:52
Midpoint circle algorithm
/// implemention of http://groups.csail.mit.edu/graphics/classes/6.837/F98/Lecture6/circle.html
use std::fs::File;
use std::path::Path;
use image::{self, GenericImage, ImageBuffer, Pixel, Rgba};
struct Point {
x: u32,
y: u32
@timgluz
timgluz / Pseudocode
Created March 1, 2017 17:11
Raise to float to any large power
// Calculate A to the power P.
Float: RaiseToPower(Float: A, Integer: P)
<Use the first fact to quickly calculate A, A2, A4, A8, and so on
until you get to a value AN where (N + 1 > P) >
<Use those powers of A and the second fact to calculate AP>
Return AP
End RaiseToPower
That's fewer multiplications than simply multiplying 7 × 7 × 7 × 7 × 7 × 7, but it's a small difference in this example.

Keybase proof

I hereby claim:

  • I am timgluz on github.
  • I am timosulg (https://keybase.io/timosulg) on keybase.
  • I have a public key whose fingerprint is DA7D CBED 148B 937D A940 6D8E 3BC3 08EA 473B 5C8C

To claim this, I am signing this object:

@timgluz
timgluz / NippyTranscoder.clj
Created March 13, 2016 16:10
Stress-data for spyglass NippyTranscoder
(def nippy-transcoder (make-transcoder :nippy))
(deftest test-nippy-transcoder
(testing "roundtrip returns correct value"
(are [k v]
(do (c/set tc k 1 v nippy-transcoder)
(is (= v (c/get tc k nippy-transcoder))))
"text" "abc"
"nil" nil
"boolean" true
"char-utf8" \ಬ