Skip to content

Instantly share code, notes, and snippets.

@rkfg
rkfg / gifcreate
Last active February 4, 2021 21:01
GIF animation script to cut a piece of video and produce a frame-accurate optimized GIF with a precise framerate.
#!/bin/sh
help () {
log "Usage: `basename $0` [-h] [-n] [-a] [-u] [-s hh:mm:ss] [-d ss] [-w px] [-f n] [-S n] [-b n] [-t subtitle.sub] [-c default | basic | fontsize | fontstyle | full] <filename> [result.gif]
-h show this help
-n turn off subtitles
-a don't open directory with frames in filemanager
-u update this script from gist. Create .gifupd file in the script's directory to automatically check for updates once per day or put the number of seconds in the file to check with that period.
-s start time in seconds or as hours:minutes:seconds, default: 0
@rkfg
rkfg / teatime
Created September 12, 2014 05:03
#!/bin/sh
TEACOUNT=8
TEADIV=
if [ -n "$1" ]
then
TEADIV="_$1"
fi
HASH=$(echo -n "teatime_$(date +%d-%m-%Y)$TEADIV" | sha256sum | sed 's/\([0-9a-f]*\) .*/\1/' | tr '[:lower:]' '[:upper:]')
TEANUMBER=$(echo "ibase=16; scale=0; $HASH % $TEACOUNT" | bc)
echo "HASH=$HASH\nTea count=$TEACOUNT\nTea number=$TEANUMBER"
@rkfg
rkfg / stwatch
Last active August 29, 2015 14:06
#!/bin/bash
APIKEY=
ADDRESS=127.0.0.1:8080
WATCHDIRS=()
WATCHREPOS=()
TIMEOUTCHANGE=5
function watchdir {
local CHANGED
local EVENTS
@rkfg
rkfg / gist:bf85ab97b9a7783e57f9
Last active August 29, 2015 14:27
PulseAudio monitor switch
#!/bin/sh
INDEX=$(pacmd list-source-outputs | sed -n 's#\s*index\: \([0-9]*\)#\1#p' | head -n 1)
if [ -z "$INDEX" ]
then
exit 1
fi
MONITOR=$(pacmd list-sources | sed -n 's#\s*name: <\(.*\.monitor\)>#\1#p' | head -n 1)
INPUT=$(pacmd list-sources | sed -n 's#\s*name: <\(.*_input.*\)>#\1#p' | head -n 1)
#!/bin/sh
FLAGS=-v
if [ "$1" = "-n" ]
then
FLAGS="$1"
shift
fi
rename $FLAGS 's#(^\[[^]]*\])[ _]?(.+?)(\.([a-zA-Z0-9]*$)|$)#$2 $1$3#' "$@"
@rkfg
rkfg / shitpost.sh
Created October 17, 2015 13:58
Shitpost
#!/bin/sh
TEXT=$(xsel | awk '{print toupper($0)}')
(echo
echo $TEXT | sed 's#\(.\)#\1 #g'
echo $TEXT | sed 's#.\(.*\)#\1#' | sed 's#\(.\)#\1\n#g') | xsel -ib
@rkfg
rkfg / ipics.sh
Last active October 26, 2015 03:44
ipfs.pics uploader
#!/bin/sh
FLAGS=
PICSPATH=
PREFIX=http://ipfs.pics/
if [ -d "$1" ]
then
FLAGS=-r
else
PICSPATH=ipfs/
fi
NeuralNetConfiguration.Builder builder = new NeuralNetConfiguration.Builder();
builder.iterations(1).learningRate(LEARNING_RATE).rmsDecay(RMS_DECAY)
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(123).miniBatch(true).updater(Updater.RMSPROP)
.weightInit(WeightInit.XAVIER).regularization(true).l2(L2)
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer);
GraphBuilder graphBuilder = builder.graphBuilder().pretrain(false).backprop(true).backpropType(BackpropType.TruncatedBPTT)
.tBPTTBackwardLength(TBPTT_SIZE).tBPTTForwardLength(TBPTT_SIZE);
graphBuilder.addInputs("firstLine").setInputTypes(InputType.recurrent(dict.size()))
.addLayer("encoder", new GravesLSTM.Builder().nIn(dict.size()).nOut(HIDDEN_LAYER_WIDTH).activation(Activation.TANH).build(),
@rkfg
rkfg / Main.java
Last active March 13, 2017 12:03
My dl4j test code
package dlchat;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
package dlchat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.dataset.api.MultiDataSet;