Acceder a una base de datos ms-access desde c# en windows 2003 64bit

Windows 2003 server 64bit no incluye los drivers OLEDB para poder acceder a una base access.

Para que una aplicación en c# funcione, se debe compilar como 32bit, para obligar a que el server utilice 32bits para su ejecución, y entonces sí poder tener acceso a dichos drivers.

En Proyecto/propiedades/Generar, elegir en destino de la plataforma (platform target), x86.
Si se deja en Any CPU, se ejecutará como 64bits y no tendrá acceso a los drivers.

Utilizar libreria de C++ desde Java

En visual studio 2008:

1. Crear el archivo java:

public class p
{
   private static native int prueba();
   public static void main(String[] args)
   {
   }
   static {
     System.loadLibrary("Lib2");
     System.out.println(prueba());
   }
}

2. Compilarlo:
          javac p.java

3. Crear el archivo de encabezado (p.h)
         javah -jni p

4. Crear una biblioteca de clases de C++ (llamarla Prueba)
5. Abrir prueba.cpp y agregar el siguiente código:

#include "stdafx.h"#include "p.h"JNIEXPORT jint JNICALL Java_p_prueba
(JNIEnv *jniEnv, jclass clazz)
{
return 12345;}

  6. Compilar la DLL y copiarla a c:\windows\system32

7. Ejecutar
       java p


Imprimir pdf en multiples paginas (poster, tile)

Download and install a PDF reading program that has a feature called page scaling. The following steps apply to Adobe Acrobat Reader, Foxit Reader and Nitro PDF Reader. All of these programs include page scaling as a print feature, and all are available as a free download.
2
Open the PDF reading program you just installed. Click the "File" menu and select the "Print" option to launch the "Print" dialog window. Enter the number of the page that you want to print onto multiple pages in the "Pages" field in the "Print Range" section.
3
Click the "Page Scaling" drop-down menu in the "Page Handling" section and select the "Tile All Pages" option.
4
Enter the percentage that you want the PDF enlarged into the "Tile Scale" field. Doing this changes the PDF image in the preview pane. It displays the number of pages that the PDF will print onto.
5
Click the "Cut Marks" box to add guidelines that identify where to cut any overlap, if necessary. Click the "Labels" box to mark each page with a page number so that you can easily identify the appropriate order. Click the "OK" button to print the pages


Fuente: https://itstillworks.com/do-multiple-pages-using-pdf-8087692.html




Controlar Authorization en WebApi C#

Agregar con NuGet el package: Microsoft.AspNet.WebApi.Cors

En un WebApi:

using System.Web.Http.Cors;

var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);

config.Formatters.JsonFormatter.SupportedMediaTypes
.Add(new MediaTypeHeaderValue("text/html"));

config.Filters.Add(new FiltroAuth());





Ionic

 

Debug en celular

1. Habilitar debug USB en el telefono
2. ionic cordova run android --device
3. Para ver el output de consola que produce el celular:

Debug en chrome
Abrir chrome:
Buscar la que dice Ionic App, y click en Inspect



0. Setup inicial

instalar NativeScript y ejecutar tsn doctor
esto instala todo lo necesario (sdk de android, gradle, etc)

1. Iniciar proyecto

ionic start proyecto1 blank --type=angular
cd proyecto1
npm install --save @angular/material @angular/cdk

ng add @angular/material

Si no funciona: npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install


2. Previsualizar

ionic serve -l --livereload     //-l es para iniciar en modo lab, previsualiza en ios y android


*** Si livereload no anda:
npm uninstall -g ionic
npm install -g ionic@latest
npm i -g ionic
***

3. Todos los componentes Material

https://expressraider.blogspot.com/2019/02/importacion-de-todos-los-modulos-de.html

(referencia: https://gist.github.com/pimatco/d5b1891feb90b60ca4681011b6513873)


4. Referencia API Material

REFERENCIA
https://material.angular.io/components/categories

QUICK GUIDE
https://www.tutorialspoint.com/angular_material7/angular_material7_quick_guide.htm

ALLIGATOR
https://alligator.io/angular/material-design-angular-reference/


5. Firestore

npm install angularfire2 firebase


*** si da error TypeError:

npm install rxjs@6 rxjs-compat@6 --save
***


mas detalles en: http://expressraider.blogspot.com/2018/08/firebase-ionic-angular.html?m=0


6. Navegación

app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'home', loadChildren: './home/home.module#HomePageModule' },
  { path: 'resultado', loadChildren: './resultado/resultado.module#ResultadoPageModule' }

];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }


home.page.ts

import { NavController } from '@ionic/angular';

constructor(public navCtrl: NavController) {}

this.navCtrl.navigateForward('resultado');








---------------------------------------------------------------------------------------------------------------------



Para ver todos los templates disponibles:
ionic start app1 --list


Instalar Gradle

1. Bajar la ultima version de gradle de esta ubicacion: https://gradle.org/install/
y descomprimirla en c:\gradle
*** bajar la version full ***

2. Agregar al path: c:\gradle\bin

3. Ejecutar gradle -v para verificar que haya quedado ok.


Configuración para poder compilar para Android:

INSTALAR ANDROID STUDIO
ESTO INSTALA EL SDK MANAGER DE FORMA CORRECTA

https://ionicframework.com/docs/v3/developer-resources/platform-setup/windows-setup.html

1. Instalar Java JDK (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
2. Instalar Android SDK (https://developer.android.com/studio/index.html#downloads)
3. Abrir SDK manager e instalar:
     
  • Android Platform SDK for your targeted version of Android
  • Android Platform-Tools
  • Android SDK build-tools version 19.1.0 or higher
  • Android Support Repository (found under “Extras”)
4. Instalar Gradle (https://gradle.org/)
5. Configurar las variables de entorno:

              ANDROID_HOME : The path to where the Android SDK is installed.

              PATH : Two entries, one where Tools are installed for the Android SDK, and another for Platform tools
              GRADLE_HOME : The path to where gradle is installed

Para agregar las variables desde linea de comando:


set ANDROID_HOME=C:\<installation location>\sdk

set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
set GRADLE_HOME=C:\<installation location>

6. Verificar que se pueda ejecutar

                java -version
                android

(Esto indica que esta todo bien instalado)




7. En la carpeta del proyecto ejecutar

ionic cordova platform add windows




Compilación en Android

Luego que esta todo lo del paso anterior configurado:

ionic cordova build android       Generar el apk para probar en celular

*** hay que instalar android studio para que funcione la compilacion para android ***




home.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';

import { HomePage } from './home.page';
import {MatButtonModule, MatIconModule, MatSelect} from '@angular/material';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatSelectModule} from '@angular/material'
import {MatInputModule} from '@angular/material';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild([
      {
        path: '',
        component: HomePage
      }
    ]),
    MatButtonModule,
    MatIconModule,
    MatFormFieldModule,
    MatSelectModule,
    MatInputModule    
  ],
  declarations: [HomePage]
})
export class HomePageModule {}



home.page.html

<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-menu-button></ion-menu-button>
    </ion-buttons>
    <ion-title>
      Datos del cliente
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>

    <div class="example-container">
      <mat-form-field>
        <input matInput placeholder="Nombre">
      </mat-form-field>

      <mat-form-field>
          <input matInput placeholder="Dirección">
      </mat-form-field>
      
      <mat-form-field>
          <input matInput placeholder="Teléfono">
      </mat-form-field>
                  
      <mat-form-field>
        <textarea matInput placeholder="Textarea"></textarea>
      </mat-form-field>
    
      <mat-form-field>
        <mat-select placeholder="Color">
          <mat-option value="option">Rojo</mat-option>
          <mat-option value="option">Negro</mat-option>
          <mat-option value="option">Azul</mat-option>
        </mat-select>
      </mat-form-field>
    </div>    
</ion-content>


home.page.scss

.example-container {
  display: flex;
  flex-direction: column;
}

.example-container > * {
  width: 100%;
}










Tabs

<ion-tabs>
  <ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
  <ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
  <ion-tab [root]="tab3Root" tabTitle="Contactos" tabIcon="contacts"></ion-tab>
</ion-tabs>


import { Component } from '@angular/core';

import { AboutPage } from '../about/about';
import { ContactPage } from '../contact/contact';
import { HomePage } from '../home/home';

@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

  tab1Root = HomePage;
  tab2Root = AboutPage;
  tab3Root = ContactPage;

  constructor() {

  }
}

Input

<ion-content padding> 
  <ion-item> 
    <ion-input  [(ngModel)]="filtro" type="text" placeholder="Numero"></ion-input>
    <button ion-button item-end (click)="buscar();">Buscar</button>
  </ion-item>
</ion-content>

Tabla

<ion-content padding> 

  <ion-grid>
    <ion-row *ngFor="let d of lista">
      <ion-col>
        {{d.id}}
      </ion-col>
      <ion-col>
        {{d.titulo}}
      </ion-col>
      <ion-col>
        {{d.etapa}}
      </ion-col>
    </ion-row>
  </ion-grid>

</ion-content>

Boton1

<button ion-button>Guardar</button>

Boton 2 (bloque)

  <div padding>
    <button ion-button color="primary" block>Guardar</button>
  </div>

Pasar datos de una pagina a otra

    this.navCtrl.push(ListaCompraPage, {
      codigo: this.codigo,
      descripcion: this.descripcion,
      precio: this.precio,
      cantidad: this.cantidad
    });

Variables globales

ionic generate provider global

import { Injectable } from '@angular/core';
import { Articulo } from '../../app/models/articulo';

@Injectable()
export class GlobalProvider {
  public lista: Articulo[];

  constructor() {
    this.lista = []; 
  }

}

para utilizarlo:

constructor(public global: GlobalProvider) {
  }

console.log(global.lista);






Capturar screenshot con IONIC Cordova

ionic cordova plugin add com.darktalker.cordova.screenshot

npm install @ionic-native/screenshot

import { Screenshot } from '@ionic-native/screenshot'; 


    Screenshot.save('jpg', 80, 'myscreenshot.jpg').then(res => {
      this.url = res.filepath;

    });

**No poner Screenshot en el constructor ni en app.module!!!

Hostear Node.js en Heroku

https://dashboard.heroku.com/apps/gastos-2020/deploy/heroku-git


1. Descargar Heroku Cli
2. cmd > heroku login
3. Crear aplicacion en Heroku (ej, gastos-2020)
4. ir a la carpeta donde está el codigo fuente de la aplicación node.js
5. Deploy:
       git add .
       git commit -am "make it better"

       git push heroku master

Máscaras de latex - Batman


Tips
200g de talco industrial por lt de látex

Prototipo 1



































EasyDriver CNC

ATENCION!
Los comandos para configurar GRBL no funcionan en el serial monitor del arduino!
Usar el mismo Gcode sender para configurarlo, o el software de terminal CoolTerm


Quick setup guide
http://blog.protoneer.co.nz/quick-grbl-setup-guide-for-windows-arduino-g-code-interpreter/

Pin layout de EasyDriver
http://blog.protoneer.co.nz/grbl-arduino-g-code-processor-pin-layout/

Configuración de GRBL 0.8
https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.8

Calculadora GRBL de ShapeOko
http://noblesque.org.uk/ShapeOko/grblcalc/

Software para dibujar para ShapeOko
http://zapmaker.org/projects/grbl-controller-3-0/

Sleep y Enable explicados:
http://xavierstechno.blogspot.com.es/#%21/2012/02/easy-driver-with-arduino.html

Ejemplos de GCODE
https://github.com/grbl/grbl/wiki/G-Code-Examples

Manual de GCODE
http://linuxcnc.org/docs/html/gcode.html

VER SHAPEOKO!
http://www.shapeoko.com/

Usar servo en eje Z
https://github.com/grbl/grbl/issues/220

There is a mod/fork of an old 0.8 grbl version which can use a servo on the Z-Axis:
https://github.com/heise/GRBLDRILL
It was done by the german ct magazin for a small PCB drill.
Unfortunately there is not much documentation about that, as far is i remember the servo does a full movement if you drive Z-Axis from 0 to +5mm via gcode. This can be changed somewhere in the code.
Just try the hex file from the github: https://github.com/heise/GRBLDRILL/blob/master/GRBL/grbl.hex
with a servo connected to analog4 on the Arduino.
Here is the link top the article, but you'll have to buy ist:
https://www.heise.de/artikel-archiv/ch/2012/03/068_Dreiachs-Motorsteuerung-mit-Arduino

Software online para GCODEhttp://www.makercam.com/
Código fuente de GRBL e instrucciones para cargar en Arduino
http://blog.protoneer.co.nz/grbl-arduino-library/

GRBL Arduino Library – Use the Arduino IDE to flash GRBL directly to your Arduino

We have created an Arduino Library of the popular GRBL g-code Interpreter. A great little application that turns your Arduino into a very capable CNC machine.
This library makes it so much easier to install GRBL onto your Arduino. No more issues with making HEX files or trying to find a way to upload the Hex file to your board. Simply install the library and open the right example sketch for your Arduino.
How to install it:
  • Down load the library from GitHub : https://github.com/Protoneer/GRBL-Arduino-Library/archive/master.zip
  • Unzip the library and copy the main folder into the “Libraries” folder in the folder you installed your Arduino software. Eg. C:\arduino-1.0.3\libraries\
  • Rename the folder to “GRBL”. (This will stop the Arduino IDE from complaining about the long folder name)
  • Open up the Arduino IDE.
  • Click on the following menu : File -> Examples – > GRBL (or what ever you renamed the folder to) -> ArduinoUno
  • Upload the sketch to you Arduino UNO board.
If you are interested in the source code, its available at https://github.com/Protoneer/GRBL-Arduino-Library


Configuración de corriente para el Big EasyDriver

Subir este codigo al arduino, y con un destornillador girar el potenciometro para encontrar el punto en que el motor gira bien.



  ////////////////////////////////              
  //TWO WIRE STEP/DIR DRIVER BOARD CODE      
  int Motor1StepPin = 4;
  int Motor1DirPin = 7;

  int Motor2StepPin = 2;
  int Motor2DirPin = 3;  
  
  //The number of steps required for your stepper to make one revolution. (Don't forget to take into 
  //account the settings on your driver board. i.e. Microstepping, half stepping etc.)
  float steps = 200;  
    //Set the travel speed for your stepper motors here. (In Rev/Min)
    //Note: There is a limit to how fast or slow this code is able to spin the stepper motors.
    //You can try experimenting with the "delayMicroseconds" code if you need different speeds.
  int altSpeed=60;
  int azSpeed=60; 
  
  //////////////////////////////// 

  float Motor1Delay, Motor2Delay, doSteps;

void setup()

    Serial.begin(9600);
  ////////////////////////////////              
  //TWO WIRE STEP/DIR DRIVER BOARD CODE  
  pinMode(Motor1StepPin, OUTPUT);
  pinMode(Motor1DirPin, OUTPUT);
  pinMode(Motor2StepPin, OUTPUT);
  pinMode(Motor2DirPin, OUTPUT);
  Motor1Delay = ( 1000000 * ( 60 / (steps * altSpeed) ) ) / 2;
  Motor2Delay  = ( 1000000 * ( 60 / (steps * azSpeed) ) ) / 2;
  ////////////////////////////////  

        pinMode(6, OUTPUT);
//      pinMode(7, OUTPUT);      
//      pinMode(13, OUTPUT);
    

         
}

void loop()
{
  
  delay(1000); 
  digitalWrite(6, LOW);
  delay(100); 
  
  moveToPosition(1, 0, -steps * 1);  
  moveToPosition(1, 0, steps * 1);   
  moveToPosition(1, -steps * 1, 0); 
  moveToPosition(1, steps * 1, 0); 

  digitalWrite(6, HIGH);  

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This code moves the stepper motors
void moveToPosition(int limitSearch,  long altsteps, long azsteps){
    
//    Serial.println("altsteps");
//    Serial.println(altsteps);
//    Serial.println("azsteps");
//    Serial.println(azsteps);                 
        
  ////////////////////////////////              
  //TWO WIRE STEP/DIR DRIVER BOARD CODE   
  if (abs(azsteps)==azsteps){digitalWrite(Motor2DirPin, HIGH);}else{digitalWrite(Motor2DirPin, LOW);}  
  if (abs(altsteps)==altsteps){digitalWrite(Motor1DirPin, HIGH);}else{digitalWrite(Motor1DirPin, LOW);}

  for (doSteps=1; doSteps <= abs(azsteps); doSteps++){
     digitalWrite(Motor2StepPin, HIGH);
     delayMicroseconds(int(Motor2Delay));
     digitalWrite(Motor2StepPin, LOW); 
     delayMicroseconds(int(Motor2Delay));
  }
     
  for (doSteps=1; doSteps <= abs(altsteps); doSteps++){
     digitalWrite(Motor1StepPin, HIGH);
     delayMicroseconds(int(Motor1Delay));
     digitalWrite(Motor1StepPin, LOW); 
     delayMicroseconds(int(Motor1Delay));
  }
    
}