Skip to content

Instantly share code, notes, and snippets.

<?php
$fp = fopen('power.log', 'a+');
$oldPower = 0;
while (true) {
$power = (int)`pmset -g batt | awk ' /InternalBattery-0/ { print $3 }'`;
if ($oldPower != $power) {
$oldPower = $power;
fputcsv($fp, [date('c'), time(), $power]);
package flink;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
[3e26f1ec41a7:21000] > create table test(a int, b int, c int);
Query: create table test(a int, b int, c int)
Fetched 0 row(s) in 0.07s
[3e26f1ec41a7:21000] > insert into test values (1,2,3);
Query: insert into test values (1,2,3)
Query submitted at: 2018-03-14 15:01:11 (Coordinator: http://3e26f1ec41a7:25000)
select * from test;
3e26f1ec41a7:21000] > create table test (a int, b int);
Query: create table test (a int, b int)
Fetched 0 row(s) in 0.77s
[3e26f1ec41a7:21000] > insert into test values (1,2), (3,4);
Query: insert into test values (1,2), (3,4)
Query submitted at: 2018-03-14 14:57:06 (Coordinator: http://3e26f1ec41a7:25000)
select * from test;
Query progress can be monitored at: http://3e26f1ec41a7:25000/query_plan?query_id=8f483cc1be99748d:be8e17e500000000
Modified 2 row(s) in 6.64s
<?php
$dict = json_decode(file_get_contents('/Users/Sirko/Library/Application Support/plover/main.json'), true);
$dictKeys = array_keys($dict);
$inputText = strtolower('this is the first input text');
echo($inputText."\n");
$inputTextWords = explode(' ', $inputText);
@OutOfBrain
OutOfBrain / InjectLoggerTest.java
Created May 22, 2017 13:51
Guice custom logger annotation without additional dependencies
public class InjectLoggerTest {
@InjectLogger
private Logger logger;
public static void main(String[] args) throws Exception {
final Injector injector = Guice.createInjector(new ModuleInjectLogger());
final InjectLoggerTest injectLoggerTest = injector.getInstance(InjectLoggerTest.class);
injectLoggerTest.f();
@OutOfBrain
OutOfBrain / raspi_stream.sh
Last active July 7, 2017 10:52
start a stream on raspberry pi and have a script capturing it
# start a stream on raspberry pi
raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream}' :demux=h264
# save raspberry pi camera stream
ffmpeg -i rtsp://@192.168.0.206:8554/stream -an -c:v libx264 output.mp4
# another version that seems to work - but very slow:
raspivid -o - -t 99999 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
@OutOfBrain
OutOfBrain / MontyHallSimulation.java
Created January 29, 2017 01:16
Monty Hall Problem Simulation
import java.util.Random;
public class MontyHallSimulation {
public static void main(String[] args) {
new MontyHallSimulation().start();
}
private Random rand = new Random(4);
@OutOfBrain
OutOfBrain / startopenssh.sh
Last active November 24, 2016 18:28
Start an openssh server on the fly somewhere- still missing installing docker in the first place
# curl https://gist.githubusercontent.com/.../startopenssh.sh | bash
wget https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz
tar -xvzf docker-latest.tgz
mv docker/* /usr/bin/
nohup dockerd &
OVPN_DATA="ovpn-data"
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://$(ifconfig | grep -A 5 eth0 | awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}')
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn sh -c 'echo -e "yes\nblep\n" | ovpn_initpki nopass'
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full thecert nopass
@OutOfBrain
OutOfBrain / gist:23d8be9dbe4403f6f9fa17a572109d37
Created June 23, 2016 22:25
Slither.io MODS with Zoom and Less Latency for Tampermonkey
// ==UserScript==
// @name Slither.io Mods
// @namespace DerpCookiePrograms
// @version 0.1
// @description Sliter.io Mods
// @author DerpCookiePrograms
// @match http://slither.io/*
// @grant none
// ==/UserScript==