Skip to content

Instantly share code, notes, and snippets.

Sami Salkosuo samisalkosuo

Block or report user

Report or block samisalkosuo

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
@samisalkosuo
samisalkosuo / generate_username.py
Last active Jan 5, 2017
Simple function to generate random usernames.
View generate_username.py
import sys
def generate_username(formatStr,capitalize=True):
"""Generate random user name. formatStr is like CVC-CVC which generates username with consonant-vowel-consonant-consonant-vowel-consonant.abs
C=consonant
V=vowel
N=number
+=space
"""
@samisalkosuo
samisalkosuo / create_ios__icons.sh
Created Dec 14, 2015
Create iOS icons from source image.
View create_ios__icons.sh
#!/usr/bin/env bash
#uses clpargs
#https://github.com/samisalkosuo/clpargs
source $GITDIR/clpargs/clpargs.bash
clpargs_program_description "Create iOS app icons from original 1024x1024 icon."
#iOS icon sizes
#https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
View lsp.bash
#!/usr/bin/env bash
if [[ "$1" != "" ]] ; then
cd $1
fi
ls -1 | sed "s;^;$(pwd)/;"
@samisalkosuo
samisalkosuo / maze.py
Last active Nov 17, 2017
Some mazes classes translated from Ruby from book: Mazes for Programmers (https://pragprog.com/book/jbmaze/mazes-for-programmers). Used in MazinGame: https://github.com/samisalkosuo/mazingame
View maze.py
#!/usr/bin/env python
#Some mazes classes translated from Ruby
#from book "Mazes for Programmers" by Jamis Buck.
#https://pragprog.com/book/jbmaze/mazes-for-programmers
#
#Includes modifications.
#
#Execute this and you see mazes.
@samisalkosuo
samisalkosuo / deploy_i2iap.sh
Created Jun 24, 2015
Script to deploy i2 IAP v3.0.11 in IBM PureApplication environment. Check this too: http://sami.salkosuo.net/silent-service-i2-iap/.
View deploy_i2iap.sh
echo Deploying i2 IAP 3.0.11 example deployment
function changeString {
if [[ $# -ne 3 ]]; then
echo "$FUNCNAME ERROR: Wrong number of arguments. Requires FILE FROMSTRING TOSTRING."
return 1
fi
SED_FILE=$1
FROMSTRING=$2
@samisalkosuo
samisalkosuo / rapod.py
Created Feb 10, 2015
Random Astronomy Picture of the Day from http://apod.nasa.gov/.
View rapod.py
#!/usr/bin/python
#retrieve random Astronomy Picture of the Day
#from http://apod.nasa.gov/
import sys
import datetime
import urllib
import urllib2
import random
View calc.sh
#!/bin/sh
bc << EOF
scale=4
$@
quit
EOF
@samisalkosuo
samisalkosuo / getpragpub.sh
Created Jan 20, 2015
Shell script to get all PragPub magazines.
View getpragpub.sh
#!/bin/sh
echo "Retrieving all 49 issues of PragPub as epub..."
echo "Downloading files to $DIR..."
DIR=pragpub
mkdir $DIR
function getPragPub {
@samisalkosuo
samisalkosuo / gist:203a580a9c7e901377e7
Last active Aug 29, 2015
Multiply-with-carry pseudo random number generator by George Marsaglia. Code from: http://en.wikipedia.org/wiki/Random_number_generation
View gist:203a580a9c7e901377e7
m_w = 0x46ab2f73d #must not be zero, nor 0x464fffff
m_z = 0xa368bbec #must not be zero, nor 0x9068ffff
def mwc():
global m_w
global m_z
m_z = 36969 * (m_z & 65535) + (m_z >> 16)
m_w = 18000 * (m_w & 65535) + (m_w >> 16)
return (m_z << 16) + m_w #32-bit result
@samisalkosuo
samisalkosuo / changestr.sh
Created Dec 10, 2014
Change string in file.
View changestr.sh
#!/bin/sh
#change string in file
if [[ $# -ne 3 ]]; then
echo "Wrong number of arguments"
echo "Usage: $0 FILE FROMSTRING TOSTRING"
exit 1
fi
SED_FILE=$1
You can’t perform that action at this time.