Skip to content

Instantly share code, notes, and snippets.

View dietercastel's full-sized avatar
💭
🤔

Dieter Castel dietercastel

💭
🤔
View GitHub Profile
@dietercastel
dietercastel / logplotrps.jl
Last active September 20, 2019 07:29
Plotting on a logaritmic scale
#Plot of calculating the win chance for g-player Rock, Paper, Scissors.
# A winning RPS game contains exactly two options.
#Total amount of options BigInt function
tot(g) = 3^BigInt(g)
#Winning options BigInt function
win(g) = 3*2*(2^(BigInt(g)-1)-1)
#Calculate the win chance
winchance(g) = win(g)//tot(g)
xto(n) = range(3,stop=n)
@dietercastel
dietercastel / plotrps.jl
Last active September 16, 2019 15:15
RPS julia plotting
#Plot of calculating the win chance for g-player Rock, Paper, Scissors.
# A winning RPS game contains exactly two options.
#Total amount of options BigInt function
tot(g) = 3^BigInt(g)
#Winning options BigInt function
win(g) = 3*2*(2^(BigInt(g)-1)-1)
#Calculate the win chance
winchance(g) = win(g)//tot(g)
xto(n) = range(3,stop=n)
@dietercastel
dietercastel / jpg2png2invert.py
Last active September 9, 2020 08:12
Convert JPG -> PNG -> INVERTED
from PIL import Image
import PIL.ImageOps
#Using PIL/pillow (install with 'pip3 install pillow' )
name = 'RPS-g2.jpg'
outname = 'RPS-g2.png' #png extension
im = Image.open(name)
inv = PIL.ImageOps.invert(im) #invert opperation
inv.save(outname)
@dietercastel
dietercastel / countRPSwins.jl
Last active September 7, 2019 09:09
Julia count RPS combinations
using IterTools
using Test
# This script counts the amount of 'winning' combinations for a n-player game of Rock, Paper Scissors (RPS).
# To test the mycount function I calculated I wanted to generate all possible combinations and programatically count them.
# That's what the actualcount function does.
x = [2,3,5]
#x = ['R','P','S']
@dietercastel
dietercastel / Keybase Proof.md
Created October 12, 2017 10:59
Keybase Proof

Keybase proof

I hereby claim:

  • I am dietercastel on github.
  • I am dietercastel (https://keybase.io/dietercastel) on keybase.
  • I have a public key ASAX77iupamFpZqv-aXDYiDQVOUfAIkUN96BFAqKsuKLUQo

To claim this, I am signing this object:

import sys
import os
import numpy as np
from keras.preprocessing import image as im
from keras.models import Model,load_model
from keras import activations
from keras.backend import image_data_format,image_dim_ordering
from keras.applications.inception_v3 import InceptionV3
@dietercastel
dietercastel / getlisteningpids.sh
Created May 20, 2016 08:59
Finds pids that are listening to ports (atm tcp6 on all interfaces only). Ideas for extension include: udp/tcp/udp6, support different interfaces, generate improved output (nice grep-able overview), ...
#Finds pids that are listening to ports (atm tcp6 on all interfaces only)
netstat | grep LISTEN | grep tcp6 | awk '{print $4 }' | awk -F':' '{print $4}' > /tmp/ports.txt
#convert ports to hex
cat /tmp/ports.txt | while read myline; do printf '%x\\n' $myline ; done > /tmp/hexports.txt
#get inodes from hex ports
grep -i -f /tmp/hexports.txt /proc/net/tcp6 | awk '{print $10}' > /tmp/inodes.txt
#get pids tied to inodes
lsof | grep -f /tmp/inodes.txt | awk '{print $2}' > /tmp/pids.txt
@dietercastel
dietercastel / adbsuscript.sh
Created May 20, 2016 08:50
Run adb as root and execute the script.
#!/bin/bash
#run adb as root
adb root
cat $1 | while read line; do adb shell "$line"; done