Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Dario Garcia dario61081

🎯
Focusing
View GitHub Profile
@dario61081
dario61081 / rest-server.py
Created Nov 26, 2016 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
View rest-server.py
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
View customToast.java
Toast msg = new Toast(getActivity());
View v = View.inflate(getActivity(), R.layout.dlg_save, null);
msg.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL,0,0);
msg.setView(v);
msg.show();
@dario61081
dario61081 / customToast.java
Created Dec 2, 2016
Custom toast procedure
View customToast.java
private void msg(String message) {
Toast msg = new Toast(getActivity());
View v = View.inflate(getActivity(), R.layout.dlg_save, null);
TextView t = (TextView) v.findViewById(R.id.lbldlgsuccess);
t.setText(message);
msg.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL,0,0);
msg.setView(v);
msg.show();
}
@dario61081
dario61081 / Entities.java
Created Dec 15, 2016
Poblar listview utilizando list<type>
View Entities.java
String url = "http://app.data.com/test";
Log.w("getSucursales", "Sucursales: ");
pb_sucursales.setVisibility(View.VISIBLE);
$.getJSON(url, null, new Function() {
@Override
public void invoke($ $, Object... objects) {
String valor = objects[0].toString();
List<Sucursal> sucs = new Gson().fromJson(valor, new TypeToken<List<Sucursal>>() {
}.getType());
lst_sucursales = new SucursalesAdapter(getActivity(), R.layout.layout_suc_item, sucs);
@dario61081
dario61081 / DeliverUserMapper
Created Dec 21, 2016
Mybatis interface descriptor
View DeliverUserMapper
public interface DeliverUserMapper{
@Results(id = "DeliverUserResults", value = {
@Result(property = "usuario", column = "DLRY_USUARIO", id = true),
@Result(property = "fecha", column = "DLRY_FECHA"),
@Result(property = "estado", column = "DLRY_ESTADO"),
@Result(property = "dispositivo", column = "DLRY_DISPOSITIVO"),
@Result(property = "observacion", column = "DLRY_OBSERVACION")
})
@dario61081
dario61081 / DeliverStatusDao.java
Created Dec 21, 2016
MyBatis session factory
View DeliverStatusDao.java
public void setDeliverStatus(String username, String status) {
try (SqlSession session = getSqlSessionFactory().openSession()) {
DeliverUserMapper mapper = session.getMapper(DeliverUserMapper.class);
mapper.setDeliverStatus(username, status);
session.commit();
}
}
@dario61081
dario61081 / msg.java
Created Jan 17, 2017
SnackBarItem for error messages
View msg.java
//mensaje de error
SnackBarItem.Builder b = new SnackBarItem.Builder(getActivity());
b.setMessage(getString(R.string.str_credenciales_invalidas));
b.setSnackBarBackgroundColor(getResources().getColor(R.color.danger_dark));
b.setActionMessageColor(Color.WHITE);
b.show();
@dario61081
dario61081 / tablas.js
Created Feb 24, 2017
manejador de filtro de tablas
View tablas.js
/**
* Created by dario on 20/02/17.
*/
$(function ($, window) {
$.fn.tabla = function () {
var currentPage = 0;
var numPerPage = 10;
var $table = $(this);
/*repaginado de la tabla*/
@dario61081
dario61081 / cambios.py
Created Mar 16, 2017
Traer las cotizaciones del banco ejemplo
View cambios.py
from bs4 import BeautifulSoup
import requests
url = 'https://www.visionbanco.com/personas/servicios/mesa-de-cambios'
f = requests.get(url)
soup = BeautifulSoup(f.content, 'html.parser')
for item in soup.find_all('tr'):
for p in item.find_all('p'):
print p.text
@dario61081
dario61081 / GPSServices.java
Created Apr 18, 2017
Codigo para utilizar GoogleApiClient para el GPS
View GPSServices.java
package py.com.puntofarma.deliverytracker30.services;
import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;