woensdag 11 november 2015

kivy screenmanager

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

class MainScreen(Screen):
    pass

class AnotherScreen(Screen):
    pass

class ScreenManagement(ScreenManager):
    pass

presentation = Builder.load_file("test.kv")

class MainApp(App):
    def build(self):
        return presentation

MainApp().run()



ScreenManagement:
  #  transition: FadeTransition()
    MainScreen:
    AnotherScreen:

:
    name: 'main'

    Button:
        on_release: app.root.current = 'other'
        text: 'Another Screen'
        font_size: 50
            
:
    name: 'other'

    Button:
        on_release: app.root.current = 'main'
        text: 'back to the home screen'
        font_size: 50



dinsdag 10 november 2015

certificates Android

Sign an apk
java -jar out/host/linux-x86/framework/signapk.jar -w .x509.pem .pk8 app_name.apk app_name-signed.apk

How can I check that an Android apk is signed with a release and not debug cert?
$ jarsigner -verify -verbose -certs my_application.apk

.509.pem is the Certificate
.pk8 is the hash

content of a pem file
$ openssl x509 -in acs.qacafe.com.pem -text



jar -xvf ../foo.jar
cd META-INF
openssl pkcs7 -in TEST.RSA -print_certs -inform DER -out foo.cer


keytool -printcert -file ANDROID_.RSA
keytool -list -keystore my-signing-key.keystore

Touch Settings > Personal > Security > Credential storage > Trusted credentials. The trusted credentials screen has two tabs:
System displays certificate authority (CA) certificates that are permanently installed in the ROM of your phone.
User displays any CA certificates that you have installed yourself, for example in the process of installing a client certificate.

woensdag 4 november 2015

etags emacs


make a  python TAG file
Type in the current project directory:


find . -name "*.py" -print | tags -

For c code
find . -name '*.c' -exec etags -a {} \;


TAGS in the current directory.


in emacs:

loadfile tags
M-x visit-tags-table. This allows you to have different databases for different projects. To look up a definition, just type  
M-., then enter up a definition


zondag 1 november 2015

NFC hacking



links
http://korben.info/wp-content/uploads/defcon/SpeakerPresentations/Lee/DEFCON-20-Lee-NFC-Hacking.pdf

woensdag 28 oktober 2015

python setup.py cython

Content of setup.py


from setuptools import setup, find_packages,Extension, Command

try:
    from Cython.Distutils import build_ext
except ImportError:
    from distutils.command.build_ext import build_ext
    sources=['midistream.c']
else:
    sources=['midistream.pyx']

setup(
    name ='midistream',
    version='1.0',
    packages=find_packages(),
    cmdclass = {'build_ext': build_ext},
    ext_modules=[
    Extension('midistream', ['midistream.pyx'])
    ],
   
)


Rename midistream.py midistream.pyx 


run:

sudo python setup.py build_ext --inplace
sudo python setup.py install

midistream.o and midistream.so are made


woensdag 7 oktober 2015

emacs packages

 in scratch press C-j


install el-get
(url-retrieve
 "https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el"
 (lambda (s)
   (goto-char (point-max))
   (eval-print-last-sexp)))

zondag 31 mei 2015

kivy / python game server handling high score

server.py:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import SocketServer
import json

class MyTCPServer(SocketServer.ThreadingTCPServer):
    allow_reuse_address = True

class MyTCPServerHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        try:
            data = json.loads(self.request.recv(1024).strip())
            # process the data, i.e. print it:
            print data
            # send some 'ok' back
            self.request.sendall(json.dumps({'return':'ok'}))
        except Exception, e:
            print "Exception wile receiving message: ", e

server = MyTCPServer(('127.0.0.1', 13370), MyTCPServerHandler)
server.serve_forever()
kivy client.py:
1
2
3
4
5
6
7
8
9
10
11
import socket
import json
def send_data(score):
  data = {'message':'This is my kivy app', 'score':score}

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect(('127.0.0.1', 13370))
  s.send(json.dumps(data))
  result = json.loads(s.recv(1024))
  print result
  s.close()
buildozer.spec
# (list) Permissions
android.permissions = INTERNET



zaterdag 31 januari 2015

emacs packages



For a specific package

Where to place the el file
After placing it, say myplugin.el to your ~/.emacs.d/ directory, add the following in your .emacs file:
(add-to-list 'load-path "~/.emacs.d/")
(load "myplugin.el")
Also, in many cases you would need the following instead of the second line:
(require 'myplugin)


for normal emacs packages 

add to init.el

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)

  (package-initialise))


In emacs type: MetaX list-packages.

woensdag 21 januari 2015

sonic pi short reference




3.times { puts "Hello!" }       Hello 
[0.5, 2, 1, 4].choose
play_pattern_timed [59,64,68],[0.5]  play 59,sleep .5 play 64 sleep .5