Skip to content

Instantly share code, notes, and snippets.

View prespondek's full-sized avatar
🏠
Working from home

Peter Respondek prespondek

🏠
Working from home
View GitHub Profile
// Delete files based on .gitignore without deleting local files
git rm --cached `git ls-files -i -X .gitignore`
git commit -m "Removed folder from repository"
git push origin master
@prespondek
prespondek / AndroidDeveloperCheetSheet.kt
Last active January 30, 2019 06:42
Android development scratch pad
// Load image from assets folder
val tile = BitmapFactory.decodeStream(resources.assets.open("filename.png"), null, options)
// The amount canvas is scaling resource images (res/drawables)
var metrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(metrics)
val logicalDensity = metrics.density
// These options will scale bitmaps to fit your screen pixel density
@prespondek
prespondek / SwiftCheatSheet.swift
Last active January 29, 2019 04:41
Swift Cheat Sheet
// Swift cheat sheet.
// Comparision of Swift to C++
// I used "Learning Swift - buidling apps for macOS, iOS and Beyond" book for reference
// comment
/* comment
*/
// all the basic comparisons and arthmetic work the same a cpp + - / * || && etc
// these dont work ++, --
@prespondek
prespondek / rel_path.py
Created August 11, 2018 06:11
Generates a list of files relative to a directory. Useful for make files.
import sys, argparse, os, textwrap
if __name__ == "__main__":
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''Relative Path Generator
-----------------------
Generates a list of files relative to a rootdirectory '''),
epilog='''Written by Peter Respondek''')
parser.add_argument("-r", help="directories will be relative to this position")
parser.add_argument("-x", help="only use this file extension")
@prespondek
prespondek / PythonCheatSheet.py
Last active February 2, 2019 06:50
Useful python commands
# I use python so infequently that i forget most of the stuff i learnt when next I need to use it.
# Here are some frequently used commands. Python 3.5 NOT 2.7
# System variables:
__file__
# Absolute path to current script
# Basic Syntax:
@prespondek
prespondek / ffmpeg_ui.pyw
Last active May 11, 2017 00:32
Basic FFMpeg command line Frontend
######################################################################
#
# FFMpeg command line frontend using python and TKinter.
#
# Requires Python 2.7
#
# This is not an "easy mode" for ffmpeg. It's just a labour
# saving device for transcoding video files. You will need to download
# and install FFMpeg from http://ffmpeg.org and add ffmpeg as an
# environment variable. It's pretty basic right now but if you have
@prespondek
prespondek / lmap_wave.vert
Created April 22, 2015 12:03
Cocos2DX Wave Vertex Shader
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
attribute vec2 a_texCoord1;
varying vec2 v_texture_coord;
varying vec2 v_texture_coord1;
// height of the wave in world units.
uniform float u_amplitude;
@prespondek
prespondek / lmap_blend1.vert
Created April 22, 2015 05:19
Cocos2DX Vertex Blend and Light Map Shader
attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec2 a_texCoord1;
attribute vec2 a_texCoord2;
attribute vec4 a_color;
varying vec4 v_color;
varying vec2 v_texture_coord;
varying vec2 v_texture_coord1;
varying vec2 v_texture_coord2;
@prespondek
prespondek / lmap_alpha_mask.frag
Created April 22, 2015 04:12
Cocos2DX Alpha Mask Fragment Shader
#ifdef GL_ES
varying mediump vec2 v_texture_coord;
varying mediump vec2 v_texture_coord1;
#else
varying vec2 v_texture_coord;
varying vec2 v_texture_coord1;
#endif
uniform sampler2D lightmap;
void main(void)
attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec2 a_texCoord1;
varying vec2 v_texture_coord;
varying vec2 v_texture_coord1;
void main(void)
{
gl_Position = CC_MVPMatrix * a_position;
v_texture_coord.x = a_texCoord.x;