Skip to content

Instantly share code, notes, and snippets.

arberg

Block or report user

Report or block arberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arberg
arberg / logger.ps1
Created Sep 19, 2019 — forked from barsv/logger.ps1
Logging in powershell with log rotation
View logger.ps1
# all logging settins are here on top
$logFile = "log-$(gc env:computername).log"
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL")
$logSize = 1mb # 30kb
$logCount = 10
# end of settings
function Write-Log-Line ($line) {
Add-Content $logFile -Value $Line
Write-Host $Line
@arberg
arberg / logger.ps1
Created Sep 19, 2019 — forked from barsv/logger.ps1
Logging in powershell with log rotation
View logger.ps1
# all logging settins are here on top
$logFile = "log-$(gc env:computername).log"
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL")
$logSize = 1mb # 30kb
$logCount = 10
# end of settings
function Write-Log-Line ($line) {
Add-Content $logFile -Value $Line
Write-Host $Line
@arberg
arberg / downloadWith-YoutubeDl.sc
Created Dec 7, 2018
Download from youtubeDl with my custom video quality preference and downnload subtitles and convert vtt to srt with ffmpeg. Written in scala ammonite, so needs Ammonite to run it.
View downloadWith-YoutubeDl.sc
import ammonite.ops._
import ujson.Js.Value
import upickle.default.{macroRW, ReadWriter => RW}
//import scala.math.Ordering.Implicits._
//https://transform.now.sh/json-to-scala-case-class
case class SubLanguage(ext: String, url: String)
object SubLanguage { // uPickle 0.7.1 needs these to parse the objects. Really ugly, maybe gson is better?
implicit val rw: RW[SubLanguage] = macroRW
@arberg
arberg / downloadWith-YoutubeDl.sc
Created Dec 7, 2018
Download from youtubeDl with my custom video quality preference and downnload subtitles and convert vtt to srt with ffmpeg.
View downloadWith-YoutubeDl.sc
import ammonite.ops._
import ujson.Js.Value
import upickle.default.{macroRW, ReadWriter => RW}
//import scala.math.Ordering.Implicits._
//https://transform.now.sh/json-to-scala-case-class
case class Da(ext: String, url: String)
object Da { // uPickle 0.7.1 needs these to parse the objects. Really ugly, maybe gson is better?
implicit val rw: RW[Da] = macroRW
@arberg
arberg / linuxRedirectSerialPortToTcpWithLog.sh
Last active Nov 25, 2018
In linux redirect RS232 Serial Port traffic (in+out) to TCP port. Log all input + output to files. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
View linuxRedirectSerialPortToTcpWithLog.sh
#!/bin/bash
pid=$$
pgid=$(ps -o pgid= $$ | awk '{$1=$1;print}')
# netcat -l 7000 </dev/ttyUSB0 >/dev/ttyUSB0 &
cat /dev/ttyUSB0 | tee /var/log/lyngdorfSerial.ComToTcp.log | netcat -l 7000 | tee /var/log/lyngdorfSerial.TcpToCom.log > /dev/ttyUSB0 &
# Linux resets state when netcat closes com-port, so we need to se this after opening netcat
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb -echo
@arberg
arberg / linuxRedirectSerialPortToTcpWithLog.sh
Created Nov 25, 2018
In linux redirect RS232 Serial Port traffic (in+out) to TCP port. Log all input + output to files. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
View linuxRedirectSerialPortToTcpWithLog.sh
#!/bin/bash
# netcat -l 7000 </dev/ttyUSB0 >/dev/ttyUSB0 &
cat /dev/ttyUSB0 | tee /var/log/lyngdorfSerial.ComToTcp.log | netcat -l 7000 | tee /var/log/lyngdorfSerial.TcpToCom.log > /dev/ttyUSB0 &
# Linux resets state when netcat closes com-port, so we need to se this after opening netcat
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb
killtree() {
@arberg
arberg / WindowsHub4ComSerialRedirectToTcpPortWithTraceAndBaudRate.cmd
Last active Nov 25, 2018
In windows redirect RS232 Serial Port traffic (in+out) to TCP port. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
View WindowsHub4ComSerialRedirectToTcpPortWithTraceAndBaudRate.cmd
del log\*.log
rem Dependent on Hub4Com
rem Hub4Com Project page and download
rem https://sourceforge.net/projects/com0com/files/hub4com/
rem https://sourceforge.net/p/com0com/news/2012/06/hub4com-v2100-released/
rem Parent com0com project page (unused)
rem https://sourceforge.net/projects/com0com/
@arberg
arberg / Get-TodoistBackup.ps1
Last active Jun 11, 2018 — forked from dansmith65/Get-TodoistBackup.ps1
Powershell script to download the latest backup from Todoist - With logging and win10 notifications on failure
View Get-TodoistBackup.ps1
# Get-TodoistBackup.ps1
# Created By: Daniel Smith dan@dansmith65.com
#
# Download the latest backup from Todoist
#
# https://gist.github.com/dansmith65/7a753ddb89c9db145d41b0c4b3c7fac0
# https://gist.github.com/arberg/5c905272dd3ba41d767e0907b46cd675
# Powershell Notifications: Install-Module -Name BurntToast
$useToast=(Get-Command New-BurntToastNotification -errorAction SilentlyContinue)
@arberg
arberg / gw-simple.ps1
Last active Mar 4, 2018
Wrapping the gradle wrapper with Powershell
View gw-simple.ps1
#Finds the first gradle in the list below
#Runs gradle with the arguments to this script in current dir
$gradlePaths = @("./gradlew","../gradlew", "gradle")
$currentGradlePaths = ( $gradlePaths | ?{ gcm $_ -erroraction 'silentlycontinue' } )
if ($currentGradlePaths.Length -gt 0) {
if ($currentGradlePaths -is [array]) {
$gradle = $currentGradlePaths[0]
} else {
@arberg
arberg / MyActivity.Java
Created Feb 1, 2018
RxJava with AutoDispose: Provoke error after life cycle ends
View MyActivity.Java
package dk.bnr.androidbooking;
import android.arch.lifecycle.Lifecycle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.uber.autodispose.AutoDispose;
import com.uber.autodispose.AutoDisposePlugins;
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
You can’t perform that action at this time.