This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable 32bit architecture | |
sudo dpkg --add-architecture i386 | |
sudo apt-get update | |
# install some required packages | |
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* clones repository to existing folder */ | |
git init | |
git remote add origin PATH/TO/REPO | |
git fetch | |
git checkout -t origin/master | |
NOTE: -t will set the upstream branch for you, if that is what you want, and it usually is. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Handles session expired in AJAX requests | |
*/ | |
$(document).ajaxError(function(e, jqXHR, ajaxSettings, thrownError) { | |
// if 403 - check if user still has active session - if not redirect to login page | |
if(jqXHR.status == '403' || jqXHR.status == '500'){ | |
$.get('/users/check_session',function(data){ | |
// inactive session so redirect to login page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string FormatString(this string format, params object[] args) | |
{ | |
return string.Format(format, args); | |
} | |
// usage | |
string message = "Welcome {0} (Last login: {1})".FormatString(userName, lastLogin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var serializerSettings = new JsonSerializerSettings | |
{ | |
PreserveReferencesHandling = PreserveReferencesHandling.Objects, | |
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore | |
}; | |
string json = JsonConvert.SerializeObject(afectados, Formatting.Indented, serializerSettings); | |
return Content(JsonConvert.SerializeObject(afectados, Formatting.Indented, serializerSettings)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import os | |
filename = ... | |
with sqlite3.connect(filename) as conn: | |
conn.row_factory = sqlite3.Row | |
cursor = conn.cursor() | |
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'") | |
for tablerow in cursor.fetchall(): | |
table = tablerow[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Ubuntu Server | |
1. Set root password | |
sudo su | |
passwd | |
2. sudo /etc/init.d/mysql stop | |
3. sudo /etc/init.d/mysql start --skip-grant-tables | |
4. mysql | |
5. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; | |
6. mysql -u root -p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Change default language | |
chrome://chrome/settings/languages | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace SIMA.Core.Layers.Transversal.IoC | |
{ | |
/** ServiceAnomalias serviceAnom = ServiceContainer.Resolve<IUniverseFileServiceAdapter>() **/ | |
public static class ServiceContainer | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ adb -e pull /system/xbin/sqlite3 # get sqlite3 binary from emulator with the same CPU arch. | |
$ adb -d push sqlite3 /mnt/sdcard # push it | |
$ adb -d shell | |
$ run-as <PACKAGE_NAME> # run as your app, which should be debuggable. | |
$ cd databases; pwd | |
/data/data/<PACKAGE_NAME>/databases | |
$ cat /mnt/sdcard/sqlite3 > sqlite3 # copy it to internal storage directory | |
$ ls -l sqlite3 | |
-rw-rw-rw- u0_a138 u0_a138 36860 2014-03-26 06:37 sqlite3 | |
$ chmod 777 sqlite3 # change mode bits, to be executable |