Skip to content

Instantly share code, notes, and snippets.

@StefMa
StefMa / sendPushToGCMServer.php
Created May 20, 2015 10:54
Example of GCM-Server in PHP
<?php
// API access key from Google API's Console
// It's a Server-Key
define( 'API_ACCESS_KEY', 'YOUR_API_ACCESS_KEY' );
$registrationIds = array("DEVICE_REGISTRATION_IDS" );
// prep the bundle
$msg = array
(
@StefMa
StefMa / sendPushToGCMServer.py
Last active August 29, 2015 14:24
Example of GCM-Server in Python
try:
# Specify the url
url = 'https://android.googleapis.com/gcm/send'
# Setup the data to send
data = json.dumps({ "registration_ids" : [""+ USER_GCM_IDS +""], "data" : { "question" : data.question, "questionDetail" : data.questionDetail, "answerFormat" : data.answerFormat, "dateend" : str(data.dateend), "image" : data.image} })
# Add header
headers = {'Content-Type' : 'application/json', 'Authorization' : 'key=API_ACCESS_KEY'}
@StefMa
StefMa / README.md
Last active August 29, 2015 14:26
FindView class to remove the ugly casting of Android Views

FindView helper class


What is it?

This is a simple helper class to casting the Views of your layout file in your Activity or Fragment.


Why?

Normally you get your layout Views like this:

@StefMa
StefMa / README.md
Last active September 11, 2015 11:42
A simple Proxy Pattern in Java
@StefMa
StefMa / converter.sh
Last active August 30, 2016 07:51
Simple PNG/JPG to WebP converter
images=($(find . -iname '*.png' -o -iname '*.jpg'))
for image in "${images[@]}"; do
webp_file_path="${image::${#image}-4}.webp"
echo "Convert ${image} to ${webp_file_path}"
$(./cwebp-5.1 -quiet "${image}" -o "${webp_file_path}")
rm "${image}"
done
@StefMa
StefMa / README.md
Last active September 20, 2016 17:11
StefDefault CodeStyle

StefDefault CodeStyle

My CodeStyle for IntelliJ and AS

####Default from AS 2.2

  • Field name prefix: m
  • Static field name prefix: s
  • Final local and parameters: true
  • Right margin: true (100) [Ensure right margin is not exceeded]
  • Keep getters & setters together
@StefMa
StefMa / README.md
Created July 8, 2015 11:04
TextInputLayoutWrapperView

TextInputLayoutWrapperView


What is it?

This is a simple wrapper View for the new TextInputLayout from Design Library.


Why?

Normaly you use the TextInputLayout like this

@StefMa
StefMa / AndroidDevLinks.md
Last active March 24, 2017 08:06
Android Development Links
@StefMa
StefMa / build.gradle.kts
Created December 22, 2017 06:53
Kotlin DSL example
import com.novoda.gradle.release.PublishExtension
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.novoda:bintray-release:0.8.0")
}
}
@StefMa
StefMa / Result.md
Last active January 8, 2018 07:25
Kotlin Sequence

List Test:

Map Human(name=Stefan, age=12)
Map Human(name=Amy, age=1)
Filter Stefan
Filter Amy
[Stefan]