Skip to content

Instantly share code, notes, and snippets.

View davegreenwood's full-sized avatar

Dave Greenwood davegreenwood

  • University of East Anglia
View GitHub Profile
import pygame
pygame.init()
window = pygame.display.set_mode((1200, 400))
track = pygame.image.load("track6.png")
car = pygame.image.load("tesla.png")
car = pygame.transform.scale(car, (30, 60))
car_x = 150
car_y = 300
cam_x_offset = 0
cam_y_offset = 0
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@tin2tin
tin2tin / basic_ui_documented.py
Last active May 22, 2024 13:24 — forked from AzureDVBB/basic_ui_documented.py
A commented template for making simple UI in blender using the bpy python API
#import the bpy module to access blender API
import bpy
#WARNING: this is written and tested for blender 2.79
#blender 2.8 and newer will likely have a different python API
#create a property group, this is REALLY needed so that operators
#AND the UI can access, display and expose it to the user to change
#in here we will have all properties(variables) that is neccessary
class CustomPropertyGroup(bpy.types.PropertyGroup):
@acbetter
acbetter / QImageViewer.py
Last active April 4, 2024 19:41
Image Viewer Example by PyQt5 and Python 3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QImage, QPixmap, QPalette, QPainter
from PyQt5.QtPrintSupport import QPrintDialog, QPrinter
from PyQt5.QtWidgets import QLabel, QSizePolicy, QScrollArea, QMessageBox, QMainWindow, QMenu, QAction, \
qApp, QFileDialog
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@jirihnidek
jirihnidek / bmesh_shape_keys.py
Created September 15, 2016 19:57
Simple Blender Python script demonstrating using BMesh and Shape Keys
import bpy
import bmesh
import mathutils
def main():
"""
Example of bmesh and shape keys
"""
# Add basis shape
@kastnerkyle
kastnerkyle / beamsearch.py
Created July 8, 2016 07:34 — forked from udibr/beamsearch.py
beam search for Keras RNN
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen):
"""for every sample, calculate probability for every possible label
you need to supply your RNN model and maxlen - the length of sequences it can handle
"""
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty)
return rnn_model.predict(data, verbose=0)
def beamsearch(predict=keras_rnn_predict,
@nikitakit
nikitakit / tf_beam_decoder.py
Last active January 6, 2024 08:48
Tensorflow Beam Search
"""
Beam decoder for tensorflow
Sample usage:
```
from tf_beam_decoder import beam_decoder
decoded_sparse, decoded_logprobs = beam_decoder(
cell=cell,
@SourKream
SourKream / attentionModel.py
Created April 24, 2016 06:07
WordByWord Attention Model
class multiAttentionRNN(Recurrent):
'''
Word by Word attention model
# Arguments
output_dim: output_dimensions
init: weight initialization function.
Can be the name of an existing function (str),
or a Theano function (see: [initializations](../initializations.md)).
inner_init: initialization function of the inner cells.