Skip to content

Instantly share code, notes, and snippets.

View alxsimo's full-sized avatar
💙
Loving what I do

Alex Simonescu alxsimo

💙
Loving what I do
View GitHub Profile
@alxsimo
alxsimo / ResourceHelper.java
Created March 12, 2016 14:51
[Android] Load resources from unit test
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.net.URL;
public class ResourceHelper {
public String convertFileToString(File file) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder sb = new StringBuilder();
@alxsimo
alxsimo / git_configuration.md
Last active December 29, 2015 08:00
[git] personal git configuration

p4merge as default mergetool

  • download from oficial page
  • extract tar -xzvf p4v.tgz
  • copy the extracted P4Merge download to /opt/p4merge sudo mv * /opt/p4merge
  • symlink p4merge sudo ln -s /opt/p4merge/bin/p4merge /usr/local/bin/p4merge
  • edit ~/.gitconfig with:
[merge]
    keepBackup = false;
    tool = p4merge
@alxsimo
alxsimo / install_ruby_rvm_ubuntu.md
Created December 19, 2015 13:02
[linux] install ruby with rvm on ubuntu

Install ruby with rvm on ubuntu

Install RVM

Update repositories
sudo apt-get update

Install curl

@alxsimo
alxsimo / .bashrc
Last active November 24, 2015 10:10
[GIT] Bash actual branch
# edit .bashrc
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# with colors
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\] \[\033[33;1m\]\w\[\033[m\] (\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)) \$ "
# reload .bashrc
@alxsimo
alxsimo / db2_sample_trigger.sql
Created November 17, 2015 16:03
[DB2] Sample trigger
CREATE TABLE ARTICA.GANADORES_PREMIO_GAMIFICACION (
ID_AUT_USUARIO BIGINT NOT NULL,
IDENTIFICADOR VARCHAR(255),
FECHA TIMESTAMP,
EMAIL VARCHAR(255)
);
-- TRIGGER 100 POINTS GAMIFICATION
CREATE TRIGGER FULL_POINTS_GAMIFICATION
AFTER UPDATE ON AUT_USUARIO
@alxsimo
alxsimo / .bash_profile
Created September 29, 2015 20:22
[Linux][Personal] Bash profile
echo "Welcome Alex"
export PS1=">> "
alias hi="history"
@alxsimo
alxsimo / app-servlet.xml
Last active September 16, 2015 08:03
[Spring/Java] OAuth2 token in database
<bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.JdbcTokenStore">
<constructor-arg ref="dataSource" />
</bean>
<bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
<property name="tokenStore" ref="tokenStore" />
</bean>
@alxsimo
alxsimo / FragmentTestActivity.java
Created September 7, 2015 08:20
[Android] Handle handler messages when activity/fragment is paused
public class FragmentTestActivity extends Activity {
/**
* Used for "what" parameter to handler messages
*/
final static int MSG_WHAT = ('F' << 16) + ('T' << 8) + 'A';
final static int MSG_SHOW_DIALOG = 1;
int value = 1;
@alxsimo
alxsimo / install_java_ubuntu_15
Created September 1, 2015 21:23
[Ubuntu] Install Java on Ubuntu 15.04
My way is to remove OpenJDK, add the webupd8team's PPA and install 64-bit java8 as a packet.
Code:
sudo apt-get purge openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer