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 / hidde_log_menu
Created January 24, 2015 17:53
[Huawei] Log hidden menu for Huawei Ascen G510
Dial
*#*#2846579#*#*
You will see a hidden menu. Go ProjectMenu / Background Setting / Log setting and define the log availability (log swith) and level (log level setting)
And then make sure you restart your phone
Please note this probably only applies to Huawei phones
@alxsimo
alxsimo / device_density
Created January 22, 2015 15:42
[Android] Device display density
switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
// ...
break;
case DisplayMetrics.DENSITY_MEDIUM:
// ...
break;
case DisplayMetrics.DENSITY_HIGH:
// ...
break;
@alxsimo
alxsimo / servlet_maven
Created January 17, 2015 20:43
[J2EE] The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
@alxsimo
alxsimo / backup_linux
Last active August 29, 2015 14:13
[SYS] Backup Scripts
#!/bin/bash
# /usr/bin/backup
# Backup www folder + database
# author: Alexandru Simonescu
#
a=$(date +%T-%d_%m_%Y)
b=$(date +%d_%m_%Y)
mkdir /home/webserver_backups/$b/
cp -i -p -R /var/www/museo /home/webserver_backups/$b/museo_$a
@alxsimo
alxsimo / screen_density
Created December 25, 2014 15:31
[Android] Size and screen density
public void determineScreenDensity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int density = metrics.densityDpi;
if (density==DisplayMetrics.DENSITY_HIGH) {
Toast.makeText(this, "DENSITY_HIGH: " + String.valueOf(density), Toast.LENGTH_LONG).show();
}
else if (density==DisplayMetrics.DENSITY_MEDIUM) {
Toast.makeText(this, "DENSITY_MEDIUM: " + String.valueOf(density), Toast.LENGTH_LONG).show();
@alxsimo
alxsimo / dp2px
Created October 27, 2014 12:37
[Android] Convert DP to Pixel
private int dp2px(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
getResources().getDisplayMetrics());
}
@alxsimo
alxsimo / CustomHttpClient
Created October 7, 2014 14:40
[Java] Custom HTTP Client (Apache) with cookies
package es.ineco.sima.helper.network;
/**
* Created by alexandru.simonescu on 29/09/2014.
*/
import android.content.Context;
import android.util.Log;
import java.io.BufferedReader;
@alxsimo
alxsimo / CookieHelper
Created October 7, 2014 14:39
[Android] CookieHelper - Saves cookies retrieved from Apache HTTP Client to SharedPreferences
package com.alexsimo.utils.network;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.util.Base64InputStream;
import android.util.Base64OutputStream;
import android.util.Log;
@alxsimo
alxsimo / FuzzySearch
Last active August 29, 2015 14:06
[C#] Fuzzy search name file in folder
using DuoVia.FuzzyStrings;
/// <summary>
/// Busca el fichero con el nombre que mas se parece en la ruta elegida.
/// Si no encuentra el fichero o carpeta devuelve Excepciones.
/// Depende de DuoVia.FuzzyStrings
/// </summary>
/// <param name="path">Ruta donde buscar</param>
/// <param name="filename">Nombre del fichero a buscar</param>
/// <returns>Coincidencia mas exacta del fichero encontrado</returns>
@alxsimo
alxsimo / ExecuteCommandAsync
Created September 10, 2014 10:06
[C#] Execute command in background
/// <summary>
/// Execute the command Asynchronously.
/// </summary>
/// <param name="command">string command.</param>
public void ExecuteCommandAsync(string command)
{
try
{
//Asynchronously start the Thread to process the Execute command request.
Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));