Skip to content

Instantly share code, notes, and snippets.

Avatar

InityDev Gamezpedia

View GitHub Profile
@Gamezpedia
Gamezpedia / MoshiExtensions.kt
Created Dec 18, 2018 — forked from mg6maciej/MoshiExtensions.kt
Moshi generic type adapters
View MoshiExtensions.kt
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import java.lang.reflect.Type
// val adapter = moshi.listAdapter<MyModel>()
// val adapter = moshi.mapAdapter<String, List<MyModel>>(valueType = listType<MyModel>())
inline fun <reified E> Moshi.listAdapter(elementType: Type = E::class.java): JsonAdapter<List<E>> {
return adapter(listType<E>(elementType))
@Gamezpedia
Gamezpedia / generator.py
Created Nov 13, 2018 — forked from NikitaKozlov/generator.py
Simple Java class generator
View generator.py
import sys, os, shutil
def generateClass(directory, classNumber, methodsPerClass, mainPackage):
className = "Foo" + str(classNumber)
filePath = os.path.join(directory, className + ".java")
with open(filePath,"w+") as f:
f.write("package " + mainPackage + "." + directory + ";\n")
f.write("public class " + className + " {\n")
for i in xrange(0, methodsPerClass):
f.write("public void foo" + str(i) + "(){\n")
View ScopedViewModel.kt
open class ScopedViewModel : ViewModel() {
private val job = Job()
protected val scope: CoroutineScope = job + Dispatchers.Main
override fun onCleared() {
super.onCleared()
job.cancel()
}
}
@Gamezpedia
Gamezpedia / Output Android Assets.jsx
Created Jul 24, 2018 — forked from tlinkner/Output Android Assets.jsx
Photoshop script to output Android XHDPI, HDPI, MDPI, and LDPI PNGs
View Output Android Assets.jsx
// Output Android Assets.jsx
// 2012 Todd Linkner
// License: none (public domain)
// v1.0
//
// This scrip is for Photoshop CS6. It outputs Android XHDPI, HDPI, MDPI,
// and LDPI PNG assets from HDPI source files. The resulting PNGs will be
// placed in sub-folders within your target folder.
/*
@Gamezpedia
Gamezpedia / Output Android Icons.jsx
Created Jul 24, 2018 — forked from joshualyon/Output Android Icons.jsx
Photoshop script to output Android icons (with XXXHDPI, XXHDPI, XHDPI, HDPI, MDPI support)
View Output Android Icons.jsx
// Output Android Icons.jsx
// 2012 Todd Linkner
// License: none (public domain)
// v1.0 - base file by Todd Linkner
// v1.1 - added support for XXHDPI, XXXHDPI and added PNG to the file selector
//
// This script is for Photoshop CS6. It outputs Android icons of the
// following sizes from a source PSD at least 512px x 512px
//
// store:
View store_api_keys.md

1. Store api keys in a xml file

Put xml file "api_keys.xml" in the directory "res/value/".

api_keys.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="THE_MOVIE_DB_API_TOKEN">XXXXX</string>
</resources>
@Gamezpedia
Gamezpedia / php-pdo-mysql-crud.md
Created Dec 6, 2017 — forked from odan/php-pdo-mysql-crud.md
Basic CRUD operations with PDO and MySQL
View php-pdo-mysql-crud.md

Basic CRUD operations with PDO

CRUD = Create, Read, Update, Delete

Open a database connection

$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
@Gamezpedia
Gamezpedia / ResourceManager.hx
Created Nov 15, 2017 — forked from tiagolr/ResourceManager.hx
Embeding files load with Haxe + Openfl
View ResourceManager.hx
import haxe.io.Bytes;
import haxe.Resource;
import openfl.Assets;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.display.Loader;
import openfl.utils.ByteArray;
/**
@Gamezpedia
Gamezpedia / modulo_example.js
Created Oct 25, 2017 — forked from golanlevin/modulo_example.js
Modulo Example from Golan's Coding Train
View modulo_example.js
var nElements = 7;
var myCounter = 0;
var ping = 0;
function setup() {
createCanvas(600, 500);
}
function draw() {
background((255*(1-(ping*=0.95))), 255,255);
@Gamezpedia
Gamezpedia / strings.xml
Created Aug 16, 2016 — forked from udacityandroid/strings.xml
Android for Beginners : Spanish Localization Solution. This would be saved in the res/values-es/strings.xml file.
View strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the application. [CHAR LIMIT=12] -->
<string name="app_name">Sólo Java</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>