Ir al contenido principal

Entradas

Mostrando entradas de 2019

Flutter / List View / Padding

Padding Padding ( padding : EdgeInsets . only (top : 15.0 , bottom : 15.0 ), child : ) List View ListView todoListItems () { return ListView . builder ( itemCount : count, itemBuilder : ( BuildContext context, int position) { return Card ( color : Colors .white, elevation : 2.0 , child : ListTile ( leading : CircleAvatar ( backgroundColor : Colors .black, child : Text ( this .todos[position].id. toString ()), ), title : Text ( this .todos[position].title), subtitle : Text ( this .todos[position].date), onTap : (){ debugPrint ( "Tapped on " + this .todos[position].id. toString () ); }, ), ); }); }

Flutter / Basic Page

Basic Page void main () => runApp ( MyApp ()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build ( BuildContext context) { DbHelper helper = DbHelper (); return MaterialApp ( title : 'Todos' , theme : ThemeData ( primarySwatch : Colors .blue, ), home : MyHomePage (title : 'Todos' ), ); } } class MyHomePage extends StatefulWidget { MyHomePage ({ Key key, this .title}) : super (key : key); final String title; @override _MyHomePageState createState () => _MyHomePageState (); } class _MyHomePageState extends State < MyHomePage > { @override Widget build ( BuildContext context) { return new Scaffold ( appBar : new AppBar ( title : new Text (widget.title), ), body : TodoList (), ); } }

Flutter / SQL / Singleton / Threads

SQL In pubspec.yaml add Add dependencies dependencies : flutter : sdk : flutter sqflite : any path_provider : any intl : ^0.15.7 ^ Means above or equal to that version SINGLETON class DbHelper { static final DbHelper _dbHelper = DbHelper . _internal (); DbHelper . _internal (); factory DbHelper (){ return _dbHelper; } } Threads Can be used with Futures or Sync & Wait Initialize a DB import 'package:sqflite/sqflite.dart' ; import 'dart:async' ; import 'dart:io' ; import 'package:path_provider/path_provider.dart' ; static Database _db; Future < Database > get db async { if (_db == null ) { _db = await initializeDb (); } return _db; } Future < Database > initializeDb () async { Directory dir = await getApplicationDocumentsDirectory (); String path = dir.path + "todos.db" ; var dbTodos = await openDatabase (path, ...

Flutter / Model class

Constructor Can be many class Todo { int _id; String _title; String _descrition; String _date; int _priority; Todo ( this ._title, this ._priority, this ._date, [ this ._descrition]); Todo . withID ( this ._id, this ._title, this ._priority, this ._date, [ this ._descrition]); } Getter int get id => _id; String get title => _title; Setter set title ( String newTitle) { if (newTitle.length <= 255 ) { _title = newTitle; } } set descrition ( String newDescrition) { if (newDescrition.length <= 255 ) { _descrition = newDescrition; } } Dynamic Map < String , dynamic > toMap () { var map = Map < String , dynamic > (); map[ "title" ] = _title; map[ "description" ] = _descrition; map[ "priority" ] = _priority; map[ "date" ] = _date; if (_id != nu...

Flutter - TextField / TextEditingController / RaisedButton

Flutter theme TextStyle textStyle = Theme . of (context).textTheme.title; Use on text field TextField ( decoration : InputDecoration ( labelText : "Distance" , hintText : 'e.g. 123' , labelStyle : textStyle, border : OutlineInputBorder ( borderRadius : BorderRadius . circular ( 5.0 ) ) ), keyboardType : TextInputType .number, onChanged : ( String string) { setState (() { name = string; }); }, ), TextEditing Controller class _FuelFormState extends State < FuelForm > { String name = "" ; final _currencies = [ 'Dollars' , 'Euro' , 'Pounds' ]; String _currency = 'Dollars' ; TextEditingController textEditingController = TextEditingController (); String result = "" ; @override Widget build ( BuildContext context) { TextStyle textStyle = Theme . of (context).textTheme.title; return Scaffold ( a...

Flutter - State (Text field, Dropdown)

State To create a text field import 'package:flutter/material.dart' ; void main () => runApp ( MyApp ()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build ( BuildContext context) { return MaterialApp ( title : 'Hello you' , theme : ThemeData ( primarySwatch : Colors .blue, ), home : new HelloYou (), ); } } class HelloYou extends StatefulWidget { @override State < StatefulWidget > createState () => new _HelloYouState (); } class _HelloYouState extends State < HelloYou > { String name = "" ; final _currencies = [ 'Dollars' , 'Euro' , 'Pounds' ]; String _currency = 'Dollars' ; @override Widget build ( BuildContext context) { return Scaffold ( appBar : AppBar ( title : Text ( "Hello" ), backgroundColor : Colors .blueAccent, ), body : Co...

Flutter

Run (launch.json) "program" : "lib/main8_ui_row_col.dart" , Padding padding : EdgeInsets . only (top : 30.0 , left : 20.0 ), Columns Column ( children : < Widget > []) Rows Row ( children : < Widget > []) Align elements Expanded () Font https://fonts.google.com fontFamily : 'Fredericka' , fontWeight : FontWeight .w700, pubspec.yaml fonts : - family : Fredericka fonts : - asset : fonts/FrederickatheGreat-Regular.ttf weight : 700 Image (not support SVG) http://clipart-library.com pubspec.yaml assets : - images/5TRrG7gLc.png class BowlImage extends StatelessWidget { @override Widget build ( BuildContext context) { AssetImage myImage = AssetImage ( 'images/5TRrG7gLc.png' ); Image image = Image (image : myImage, width : 400.0 , height : 400.0 ,); return Container (child : image,); } } Button class Orderbutton extends Statel...

Python + Flask + Deploy Apache

Deploy on Apache https://www.storehubs.com/Blog/deploy-python-flask-application-apache-windows-server/ Install Apach on C:\Apache24 Download from  https://www.apachelounge.com/download/ Install  Microsoft Build Tools for Visual Studio 2019 . Install mod_wsgi pip install mod_wsgi mod_wsgi-express module-config Copy mod_wsgi-py34-VC10.so to C:\Apache24\modules On Apache edit  http.conf copy the previous result after section of LoadModule LoadFile "c:/users/erodvel/appdata/local/programs/python/python37/python37.dll" LoadModule wsgi_module "c:/users/erodvel/appdata/local/programs/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "c:/users/erodvel/appdata/local/programs/python/python37" Add after <Directory "${SRVROOT}/htdocs">  <Directory "c:/Apache24/htdocs">    Options Indexes FollowSymLinks ExecCGI    AllowOverride None    Require al...

jQuery VI (Functions: map, typeof, Modernizr, callbacks, noConflict)

Functions Create an array previous manipulation .map() Filter an array $.grep( array, function(item){    return item.property > 1; }) Describe the type as null, error, array, date, regexp typeof  variable === "function" Detect browser by feature detection Modernizr.load({  test: Modernizr. inputtypes.date,  nope : [       ".ext/datepicker.css"       , "ext/bootstrap-datepicker.js"   ],  complete : function (){       if( ! Modernizr. inputtypes.date ) {            $("input[type=date]").datepicker();      }      } }); Callbacks var c = $.CallBacks("unique stropOnFalse memory");   // Unique: one function per name,   // stopOnFalse // memory c.add( your_function ); c.fire("parameter_your_function") $.noConflict(); Release the...

jQuery V (Ajax)

AJAX Consolidation In a different js var data_service = function () {    ajaxService = function () {      return $.ajax({        url : "",        data : {}      })    }  return {     ajaxService : ajaxService,    ajaxService2 : ajaxService   } }(); Multiple Calls $.when( ajaxService, ajaxService2 )   .done( function(ajax_data, ajax_data2 ){         var  result = ajax_data[0];   }) Apply To pass an array var promises = [ajaxService, ajaxService2] $.when.apply($, promises); Other example   var   requests  = [              this . load_graph_lte ( "dashboard_LTE_KPI" ,  'main' ,  'LTE_RRC_Setup_SR' ),              this . load_gra...

JQuery III Tricks

Tricks In the console, select an element and type: jQuery._data($0,"events") Load events before documents ready $('document').on("click", "selector", function(){ }); Namespace $('element_filter').on('focus.namespace blur.namespace'), function (event){ }) $('element_filter').off('namespace'); Just-in-time inizialization $('document').on('focus', "input.date:not(.hasDatePicker)" ,  function(e){     $(this).initialize_function(); })

JQuery II (Event, CDN, selector, custom functions)

Event .delegate() .clearQueue() // remove the pending functions of be run .serialize() // creates a URL encoded text string by serializing form values. .serializeArray() .stopPropagation()  // dont tell parents .stopImmediatePropagation() // dont tell siblings jqXHR object is the return of an AJAX function .noConflict() // return the use of $ jQuery( document ).ready( function ( $ ) { // Code that uses jQuery's $ can follow here. }); .bind()    associate this context to an event .on(click, function(e){   e.originalEvent   //== "Human" // determine if was done by a "Human" }) CDN How to load jquery from CDN and locally in case of failure <script>    window.jQuery ||  document.wirte(" <script src=".../jquery.js">  </scritp>"); </script> Custom Selector $.extend( $.exp[":"] , {       function_name : function (element){   ...