Skip to content

Instantly share code, notes, and snippets.

View touchscroll.py
#!/usr/bin/env python3
import time
import evdev
from evdev import ecodes
SCROLL_FRAC = 0.1
if __name__ == '__main__':
devs = [evdev.InputDevice(path) for path in evdev.list_devices()]
dev = None
@rjeli
rjeli / main.cpp
Created Aug 24, 2019
freeing worker resources
View main.cpp
// g++ -std=c++11 main.cpp -lpthread -o main && ./main
#include <iostream>
#include <thread>
#include <atomic>
#include <chrono>
class BackgroundTask {
public:
BackgroundTask() : done_(false),
worker_(&BackgroundTask::worker_main, this) {}
View keybase.md

Keybase proof

I hereby claim:

  • I am rjeli on github.
  • I am rjeli (https://keybase.io/rjeli) on keybase.
  • I have a public key ASAcHZq4pvBCkWtaLl7lzqxAF1Uz7Hgr3flGCQswvhDefAo

To claim this, I am signing this object:

View pemdas.py
inputs = [
'1 + 1',
'2 * 2',
'1 + 2 * 3',
'( 1 + 2 ) * 3'
]
def pemdas(s):
ops = { op: p for p, l in enumerate(['+-', '*/']) for op in l }
ostk = []
View gist:c1ca78c099febc60a37289f7089423f5
private class CountingLogger<T> implements Function<T, T> {
private int every;
private int count;
private Function<Integer,String> message;
public CountingLogger(int every, Function<Integer,String> message) {
this.every = every;
this.message = message;
this.count = 0;
View Test.java
package com.eli.testproject;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) {
List<Integer> nums = new ArrayList<>();
View gist:4c9f9c70016d2cb5528bc229a1464a0f
// Set<Document> added
// Featurizer f
// sc::parallelize : List<T> -> JavaRDD<T>
Stream<Tuple2<Integer,Vector>> featurizedStream = added.stream()
.map(d -> new Tuple2(d.getId(), f.vector(d)));
JavaRDD<Tuple2<Integer,Vector>> featurized =
sc.parallelize(featurizedStream.collect(Collectors.toList()));
View profit.hs
profit :: [Int] -> Int
profit xs = f (head xs) 0 (tail xs)
where
f minVal maxDiff [] = maxDiff
f minVal maxDiff (x:xs) = f (min minVal x) (max maxDiff (x - minVal)) xs
-- O(n) time, O(1) memory