Skip to content

Instantly share code, notes, and snippets.

@Komosa
Komosa / prepipe.cpp
Created Sep 18, 2018
pass thru, but color some words and cut some lines
View prepipe.cpp
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
#define EACH(it, cont) for (auto &it: cont)
#define TermReset "\e[0m"
#define TermBlack "\e[0;30m"
#define TermRed "\e[0;31m"
View clickpad.sh
#!/bin/bash
#
# list of synaptics device properties http://www.x.org/archive/X11R7.5/doc/man/man4/synaptics.4.html#sect4
# list current synaptics device properties: xinput list-props '"SynPS/2 Synaptics TouchPad"'
#
#sleep 5 #added delay...
xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 1
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 9 # Below width 1 finger touch, above width simulate 2 finger touch. - value=pad-pixels
@Komosa
Komosa / rm_files.sh
Created Oct 13, 2017
nice awk trick
View rm_files.sh
#!/bin/bash
# remove files not in arrar 'files_to_keep'
find -type f -name '*.bin' \
| awk -v keep=" ${files_to_keep[*]} " -e 'keep !~ " "$0" "' \
| xargs -L1 -I II sh -c 'git rm -f II 2>/dev/null || rm II'
@Komosa
Komosa / stoper.html
Last active Sep 19, 2017
standup stoper
View stoper.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Stoper to keep your standup under control (at least it duration)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
text-align: center;
View htmlize.go
package main
import (
"errors"
"fmt"
"html/template"
"io"
"os"
"strings"
)
View unyaml.go
package main
import (
"flag"
"io/ioutil"
"os"
yaml "gopkg.in/yaml.v2"
)
@Komosa
Komosa / _test.go
Created Jul 11, 2016
error handling in golang tests
View _test.go
func Test(t *testing.T) {
fatalIf := func(err error) {
if err != nil {
t.Fatal(err)
}
}
err := os.MkdirAll(TEST_DATA_DIR, 0700)
fatalIf(err)
View update_test.go
func TestUpdate(t *testing.T) {
os.RemoveAll(TEST_DATA_DIR)
defer os.RemoveAll(TEST_DATA_DIR)
if err := os.MkdirAll(TEST_DATA_DIR, 0700); err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(TEST_DATA_DIR+"/number_of_partitions", []byte("2"), 0600); err != nil {
t.Fatal(err)
}
db, err := OpenDB(TEST_DATA_DIR)
@Komosa
Komosa / cookie.go
Created Mar 10, 2016
persistent cookie
View cookie.go
@Komosa
Komosa / remote.bat
Last active Feb 16, 2016
"Remote" execution of commands on windows with ssh-over-cygwin access
View remote.bat
:loop
if exist remote.done (
timeout 2
goto loop
)
call remote.recipe.bat
goto loop