Skip to content

Instantly share code, notes, and snippets.

View dario61081's full-sized avatar
🎯
Focusing

Dario Garcia dario61081

🎯
Focusing
View GitHub Profile
@dario61081
dario61081 / dynamic_blueprints.py
Created July 23, 2017 12:35 — forked from jtratner/dynamic_blueprints.py
Dynamic blueprints flask pseudocode
import os
PATH = path/to/my/blueprints/directory
BLUEPRINT = 'the_blueprint'
def import_file(path, name=None):
""" imports a file with given name and path """
# use the imp module to do actual imports
import imp
name = name or os.path.split(path)[-1].replace(".", "_")
@dario61081
dario61081 / delphi_tfield.pas
Created July 28, 2017 20:39
Uso del gettext settext de un tfield
procedure TForm1.Table1CategoryGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
case Sender.AsInteger of
1: Text := 'Electrical';
2: Text := 'Agricultural';
else
Text := '[Error]';
end;
end;
@dario61081
dario61081 / build.gradle
Created August 18, 2017 12:47
Custom apk name
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
applicationVariants.all { variant ->
variant.outputs.each { output ->
project.ext { appName = 'whpicking' }
def formattedDate = "-" + variant.versionName + "_" + variant.versionCode + "-" + new Date().format('yyyyMMddHHmmss')
def newName = output.outputFile.name
@dario61081
dario61081 / update.sh
Created September 15, 2017 15:52
script self-update
sudo apt-get -o Acquire::http::Proxy="http://user:passwort@proxy:port" update/upgrade
@dario61081
dario61081 / templates.py
Created October 5, 2017 02:36
format number w thousand
@app.template_filter('ffloat')
def _jinta2_filter_numer(number):
# return "8.,1f".format(float(number))
import locale
locale.setlocale(locale.LC_ALL, app.config['LOCALE'])
return locale.format('%.2f', number, grouping=True)
@app.template_filter('fnumber')
def do_fnumber(value):
@dario61081
dario61081 / appinfo.java
Created October 5, 2017 14:19
get information about apps
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View view = convertView;
if (view == null){
view = View.inflate(getContext(), R.layout.layout_app_item, null);
}
ResolveInfo info = getItem(position);
Drawable icon = getContext().getResources().getDrawable(android.R.drawable.sym_def_app_icon);
package py.com.puntofarma;
import org.apache.log4j.Logger;
import org.springframework.boot.devtools.filewatch.ChangedFiles;
import org.springframework.boot.devtools.filewatch.FileChangeListener;
import org.springframework.boot.devtools.filewatch.FileSystemWatcher;
import org.springframework.stereotype.Component;
import java.io.File;
import java.nio.file.Watchable;
@dario61081
dario61081 / dutils2dsql.java
Created November 14, 2017 19:47
convert date utils 2 date sql
ps.setDate(5, new java.sql.Date(m.getMoin_fch_vencimiento().getTime()));
@dario61081
dario61081 / oracle_conexion.py
Last active December 1, 2017 14:33
Conexion a BBDD Oracle con python y cx_Oracle
#Coneccion a base de datos oracle
import os
import cx_Oracle
#Config
params = {'host':'127.0.0.1','port':1521, 'database':'prod'}
settings = {'username':'user', 'userpass':'masterkey'}
#Crear conexion
tns = cx_Oracle.makedsn(params.host, params.port, params.database)
@dario61081
dario61081 / Utiles.java
Last active December 26, 2017 18:02
Utilidad para mostrar la captura de excepciones del sistema
/**
* Utilidad para mostrar la captura de exceptions del sistema
* @param context
* @param message
*/
public static void ShowException(@NonNull Context context, @NonNull String message) {
Drawable icon = context.getResources().getDrawable(android.R.drawable.ic_dialog_alert);
icon.setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);
AlertDialog.Builder dlg = new AlertDialog.Builder(context);
dlg.setIcon(icon);