Skip to content

Instantly share code, notes, and snippets.

View kikoso's full-sized avatar
💭
Learning things.

Enrique López Mañas kikoso

💭
Learning things.
View GitHub Profile
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
@kikoso
kikoso / gist:b3e00b3d7713abecbc84
Created October 14, 2014 11:37
Color your Git - Add this to your .bash_profile
function color_my_prompt {
local __user_and_host="\[\033[01;32m\]\u@\h"
local __cur_location="\[\033[01;34m\]\w"
local __git_branch_color="\[\033[31m\]"
#local __git_branch="\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
class PrintDemo {
private int i;
public void printCount() {
try {
for (i = 5; i > 0; i--) {
System.out.println("Selected number is: " + i );
}
} catch (Exception e) {
System.out.println("Thread has been interrupted.");
class PrintDemo {
public void printCount() {
try {
for (int i = 5; i > 0; i--) {
System.out.println("Selected number is: " + i );
}
} catch (Exception e) {
System.out.println("Thread has been interrupted.");
}
}
public final class Star {
/**
* Final and private attributes
*/
private final double mass;
private final String name;
private final Date fDateOfDiscovery;
public Planet (double aMass, String aName, Date aDateOfDiscovery) {
@kikoso
kikoso / Immutablestar.java
Last active January 30, 2017 10:53
Immutable Star
public final class Star {
/**
* Final and private attributes
*/
private final double mass;
private final String name;
private final Date dateOfDiscovery;
public Star (double aMass, String aName, Date aDateOfDiscovery) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue("Hello, World!");
FirebaseDatabase database = FirebaseDatabase.getInstance();
database.getReference().push().setValue("Hello world");
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("MyApp","Data changed");
}
@Override
public void onCancelled(DatabaseError databaseError) {
private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception {
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(clear);
return encrypted;
}
private static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");