Skip to content

Instantly share code, notes, and snippets.

View MichaelAquilina's full-sized avatar
😄
working with python + zsh + rust

Michael Aquilina MichaelAquilina

😄
working with python + zsh + rust
  • London, United Kingdom
View GitHub Profile
@MichaelAquilina
MichaelAquilina / aes_tool.py
Created August 19, 2013 17:48
PKCS7 Padding in python
def _pad(text, block_size):
"""
Performs padding on the given plaintext to ensure that it is a multiple
of the given block_size value in the parameter. Uses the PKCS7 standard
for performing padding.
"""
no_of_blocks = math.ceil(len(text)/float(block_size))
pad_value = int(no_of_blocks * block_size - len(text))
if pad_value == 0:
@MichaelAquilina
MichaelAquilina / gist:6578113
Created September 16, 2013 08:45
Compile Output for trying building tiled in Qt Creator.
09:43:57: Running steps for project tiled...
09:43:57: Configuration unchanged, skipping qmake step.
09:43:57: Starting: "C:\Qt\Qt5.1.0\Tools\mingw48_32\bin\mingw32-make.exe"
cd src/ && ( test -e Makefile || C:/Qt/Qt5.1.0/5.1.0/mingw48_32/bin/qmake.exe C:/Users/Michael/Development/tiled/src/src.pro -spec win32-g++ -o Makefile ) && C:/Qt/Qt5.1.0/Tools/mingw48_32/bin/mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'c:/Users/Michael/Development/build-tiled-Desktop_Qt_5_1_0_MinGW_32bit-Release/src'
cd libtiled/ && ( test -e Makefile || C:/Qt/Qt5.1.0/5.1.0/mingw48_32/bin/qmake.exe C:/Users/Michael/Development/tiled/src/libtiled/libtiled.pro -spec win32-g++ -o Makefile ) && c:/Qt/Qt5.1.0/Tools/mingw48_32/bin/mingw32-make -f Makefile
mingw32-make[2]: Entering directory 'c:/Users/Michael/Development/build-tiled-Desktop_Qt_5_1_0_MinGW_32bit-Release/src/libtiled'
c:/Qt/Qt5.1.0/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[3]: Entering directory 'c:/Users/Michael/Development/build-ti
//calculate tfidf value with given input parameters
private double TFIDF(int TermFrequency, int DocumentFrequency, int NormalizationValue, int NumberOfDocuments)
{
//it is important to specify that a divide is a double otherwise the compiler will assume its an integer since the paramaters are integers
return ((double)TermFrequency / NormalizationValue) * Math.Log(((double)NumberOfDocuments / DocumentFrequency), 2);
}
@MichaelAquilina
MichaelAquilina / gist:8283313
Created January 6, 2014 14:07
index.yaml for google app engine project
indexes:
# AUTOGENERATED
# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
31072: message: minor api issue 131204: Texture state usage warning: Texture 0 is base level inconsistent. Check texture size.
31072: message: minor api issue 131204: Texture state usage warning: Texture 0 is base level inconsistent. Check texture size.
31072: message: minor api issue 131204: Texture state usage warning: Texture 0 is base level inconsistent. Check texture size.
31072: message: minor api issue 131204: Texture state usage warning: Texture 0 is base level inconsistent. Check texture size.
31153: message: minor api issue 131188: Buffer usage warning: Analysis of buffer object 2 (bound to GL_PIXEL_UNPACK_BUFFER_ARB) usage indicates that CPU is consuming buffer object data. The usage hint supplied with this buffer object, GL_STATIC_DRAW, is inconsistent with this usage pattern. Try using GL_STREAM_READ_ARB, GL_STATIC_READ_ARB, or GL_DYNAMIC_READ_ARB instead.
31176: message: minor api issue 131188: Buffer usage warning: Analysis of buffer object 3 (bound to GL_PIXEL_UNPACK_BUFFER_ARB) usage indica
Output of command: ''/home/heman/.local/share/Steam/SteamApps/common/the witcher 2/crash_reporting/minidump_stackwalk' '/home/heman/.local/share/cdprojektred/witcher2//21862d19-fc54-1aed-14858282-1c491b2f.dmp' '/home/heman/.local/share/Steam/SteamApps/common/the witcher 2/crash_reporting/symbols/''
===============================================================================================
Operating system: Linux
0.0.0 Linux 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:02:19 UTC 2014 i686
CPU: x86
AuthenticAMD family 16 model 2 stepping 3
4 CPUs
Crash reason: SIGSEGV
Crash address: 0x0
$ optirun steam
double click W2
...
ERROR: ld.so: object '/home/me/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/me/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/me/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
** Message: window size should be 487x713
ERROR: ld.so: object '/home/me/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Setting breakpad minidump AppID = 20920
Steam_SetMinidumpSteamID: Caching Steam ID: 76561197982870345 [API loaded no]
@MichaelAquilina
MichaelAquilina / gist:a1e73df51a15e431340e
Created June 12, 2014 16:08
Steam System Info Ubuntu 14.04
Processor Information:
Vendor: GenuineIntel
CPU Family: 0x6
CPU Model: 0x2a
CPU Stepping: 0x7
CPU Type: 0x0
Speed: 2001 Mhz
8 logical processors
4 physical processors
HyperThreading: Supported
@MichaelAquilina
MichaelAquilina / gcd.py
Last active August 29, 2015 14:02
Greatest Common Divisor (Python)
#! /usr/bin/python
# Greatest Common Divisor in python
# recursive (as given)
def gcd_r(a, b):
if b == 0:
return a
#! /usr/bin/python
import gzip
import bz2
import time
import os
target_dir = '/home/michaela/Development'
t0 = time.time()