Skip to content

Instantly share code, notes, and snippets.

View 4ndrej's full-sized avatar

Andrej 4ndrej

View GitHub Profile
# syncmaster at work
xrandr --output LVDS --mode 1680x1050 --output VGA-0 --mode 1600x1200 --left-of LVDS
@4ndrej
4ndrej / gradle2pom.sh
Last active October 26, 2016 08:28
gradle to maven deps filter
cat build.gradle\
| awk '{$1=$1};1'\
| grep -i "compile "\
| sed -e "s/^compile //Ig" -e "s/^testCompile //Ig"\
| sed -e "s/\/\/.*//g"\
| sed -e "s/files(.*//g"\
| grep -v ^$\
| tr -d "'"\
| sed -e "s/\([-_[:alnum:]\.]*\):\([-_[:alnum:]\.]*\):\([-+_[:alnum:]\.]*\)/<dependency>\n\t<groupId>\1<\/groupId>\n\t<artifactId>\2<\/artifactId>\n\t<version>\3<\/version>\n<\/dependency>/g"
package main
import (
"fmt"
"math/big"
"sync"
)
func runInThread(wg *sync.WaitGroup, startFrom int64, numOfIterations int64) {
defer wg.Done()
@4ndrej
4ndrej / lsusb 1871:7670
Created January 11, 2018 12:12
lsusb of USB microscope 1871:7670
# lsusb -d 1871:7670 -v
Bus 001 Device 126: ID 1871:7670 Aveo Technology Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@4ndrej
4ndrej / decrypt-remmina.sh
Created February 9, 2018 15:54
remmina decrypt oneliner
# this works only as oneliner
# stolen from comments to https://askubuntu.com/a/379545/123435
python -c "import base64,sys;from Crypto.Cipher import DES3;pc=open('/home/andrej/.config/remmina/remmina.pref').read();pci=pc.index('secret=');secret=pc[pci:pc.index('\n',pci)].split('=',1)[1];cc=open(sys.argv[1]).read();cci=cc.index('password');password=cc[cci:cc.index('\n',cci)].split('=',1)[1];secret,password=base64.decodestring(secret),base64.decodestring(password); print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)" 1486132120333.remmina
# remmina config is at ~/.config/remmina/remmina.pref
# config files are at ~/.local/share/remmina/
@4ndrej
4ndrej / pfx2cer-key.sh
Last active March 22, 2018 17:56
pfx to key/cer chain
# convert from pfx to passwordless key/crt chain
# based on https://gist.github.com/ericharth/8334664
# params
PFX="hostname.pfx"
PASSWORD="pfxpassword"
OUT="hostname-2018"
# key
openssl pkcs12 -in $PFX -password pass:$PASSWORD -nodes -nocerts -out $OUT.key
@4ndrej
4ndrej / detect.js
Created April 27, 2018 10:05
detect mobile device using javascript
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@4ndrej
4ndrej / bashrc.sh
Last active June 6, 2018 11:59
bashrc git status
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
@4ndrej
4ndrej / xva2raw.sh
Created October 1, 2018 14:22
stitch xva's Ref/* files into raw image
#!/bin/bash
# stolen from now defunct http://wiki.sysconfig.org.uk/display/howto/Convert+Citrix+XenServer+images+to+plain+Xen
#
# To summarize the .xva format:
# - it's a tar file
# - it contains a folder
# - the folder contains chunks of 1MB each
# - they can be concatenated, but blank space needs to be filled
dd if=/dev/zero of=blank bs=1024 count=1k