Leer codigos de barra con zxing y android studio


http://expocodetech.com/lectura-de-codigo-de-barras-en-android/

http://wahidgazzah.olympe.in/integrating-zxing-in-your-android-app-as-standalone-scanner/

Invocar webservice jsonp con ajax y jquery

Este ejemplo utiliza NewtonSoft JSON que se puede bajar de acá: http://james.newtonking.com/json


En web.config del webservice:

<system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
      </protocols>
    </webServices>
</system.web>



Página que invoca al servicio:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="jquery-1.11.0.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    <input id="btn1" type="button" value="ok" />
 
 
    </div>
    </form>

<script>
    $(function() {

           var host = "http://localhost:11245/webservice1/Clientes.asmx/ObtenerClientes";

           $("#btn1").click(function() {
               $.ajax({
                   type: 'GET',
                   url: host,
                   data: { prefix: $("#txtNombreT").val() },
                   dataType: "jsonp",
                   jsonpCallback: "funcion1",
                   crossDomain: true,
                   cache: false,                                    
                   error: function(jqXHR, textStatus, errorThrown) {
                       alert(errorThrown);
                   }
               });
           });

     });



        window.localJsonpCallback = function(json) {
            if (!json.Error) {
                alert(json[0].nombre);
            }
            else {
                alert(json.Message);
            }
        }

    });

       //ojo!! esta funcion debe estar fuera del document.ready!!
       //o sino definirla como window.funcion1 = .... VER EJEMPLO ARRIBA
       function funcion1(data) {
           if (!data.Error) {
               datos = data;            
           }
           else {
               alert(data.Message);
           }
       }

</script>

</body>
</html>


Código del webservice:

Ejemplo de lo que debe retornar:

funcion1([
  {
    "nombre": "Juan",
    "documento": "23-10013"
  },
  {
    "nombre": "Pedro",
    "documento": "23-463"
  },
  {
    "nombre": "Silvia",
    "documento": "23-460"
  },
  {
    "nombre": "Fernanda",
    "documento": "23-10132"
  },
  {
    "nombre": "Ricardo",
    "documento": "2-21539085001"
  }
]);


    Public Class pers
        Public nombre As String
        Public documento As String
    End Class

    <WebMethod()> _
    <ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)> _
    Public Sub ObtenerClientes(ByVal prefix As String, ByVal callback As String)
        'Mantis 25829 - rmeneses

        'Dim personas As New List(Of String)()
        Dim personas As New List(Of pers)()

        Dim odb As New SqlDb
        Dim nombre As String

        odb.AbrirDB()
        odb.BeginTran()

        cifIO.cli.LeerClientesBusquedaIncrementalTodos(odb, prefix)

        Dim s As String = ""

        For i As Integer = 0 To odb.dt.Rows.Count - 1
            nombre = CType(odb.dt.Rows(i).Item(3), String)

            s = "{" & Chr(34) & "nombre" & Chr(34) & ": " & Chr(34) & nombre.Trim() & Chr(34) & ", " & _
                          Chr(34) & "documento" & Chr(34) & ": " & Chr(34) & odb.dt.Rows(i).Item(0) & "-" & odb.dt.Rows(i).Item(1) & "-" & odb.dt.Rows(i).Item(2) & Chr(34) & "}"

            Dim p As pers = New pers()
            p.nombre = nombre.Trim()
            p.documento = odb.dt.Rows(i).Item(0) & "-" & odb.dt.Rows(i).Item(1)

            personas.Add(p)
        Next

        Dim sb As New StringBuilder()
        sb.Append(callback & "(")
        sb.Append(JsonConvert.SerializeObject(personas, Formatting.Indented))
        sb.Append(");")

        odb.CommitTran()
        odb.CerrarDB()

        Context.Response.Clear()
        Context.Response.ContentType = "application/json"
        Context.Response.Write(sb.ToString())
        Context.Response.End()
    End Sub


Publicacion en google play con AdMob

Instrucciones
https://support.google.com/googleplay/android-developer/answer/113469?hl=es

Consola de Google Play
https://play.google.com/apps/publish/?dev_acc=07590441329928551932#AppListPlace



http://help.yoyogames.com/entries/24461331-Ads-AdMob

http://www.startcapps.com/blog/como-registrarse-como-desarrollador-en-google-play-y-app-store/

https://play.google.com/apps/publish/?dev_acc=07590441329928551932#InAppPlace:p=com.expressraider.Simon

https://apps.admob.com/?pli=1#monetize/adunit:edit/id=9155234413



Wiichuck con Arduino

Versión de ide: 1.0.5

Diagrama de conexión:

conectar el adaptador en las entradas analogas 2, 3, 4 y 5

Código:

/*
 * NunchuckPrint
 *
 * 2007 Tod E. Kurt, http://todbot.com/blog/
 *
 * The Wii Nunchuck reading code is taken from Windmeadow Labs
 *   http://www.windmeadow.com/node/42
 */

#include <Wire.h>

void setup()
{
  Serial.begin(19200);
  nunchuck_setpowerpins(); // use analog pins 2&3 as fake gnd & pwr
  nunchuck_init(); // send the initilization handshake
  Serial.print ("Finished setup\n");
}

void loop()
{
  nunchuck_get_data();
  nunchuck_print_data();
  delay(100);
}


//
// Nunchuck functions
//

static uint8_t nunchuck_buf[6];   // array to store nunchuck data,

// Uses port C (analog in) pins as power & ground for Nunchuck
static void nunchuck_setpowerpins()
{
#define pwrpin PORTC3
#define gndpin PORTC2
    DDRC |= _BV(pwrpin) | _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    PORTC |=  _BV(pwrpin);
    delay(100);  // wait for things to stabilize      
}

// initialize the I2C system, join the I2C bus,
// and tell the nunchuck we're talking to it
void nunchuck_init()
{
  Wire.begin();                // join i2c bus as master
  Wire.beginTransmission(0x52); // transmit to device 0x52
  Wire.write(0x40); // sends memory address
  Wire.write(0x00); // sends sent a zero.
  Wire.endTransmission(); // stop transmitting
}

// Send a request for data to the nunchuck
// was "send_zero()"
void nunchuck_send_request()
{
  Wire.beginTransmission(0x52); // transmit to device 0x52
  Wire.write(0x00); // sends one byte
  Wire.endTransmission(); // stop transmitting
}

// Receive data back from the nunchuck,
int nunchuck_get_data()
{
    int cnt=0;
    Wire.requestFrom (0x52, 6); // request data from nunchuck
    while (Wire.available ()) {
      // receive byte as an integer
      nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.read());
      cnt++;
    }
    nunchuck_send_request();  // send request for next data payload
    // If we recieved the 6 bytes, then go print them
    if (cnt >= 5) {
     return 1;   // success
    }
    return 0; //failure
}

// Print the input data we have recieved
// accel data is 10 bits long
// so we read 8 bits, then we have to add
// on the last 2 bits.  That is why I
// multiply them by 2 * 2
void nunchuck_print_data()
{
  static int i=0;
  int joy_x_axis = nunchuck_buf[0];
  int joy_y_axis = nunchuck_buf[1];
  int accel_x_axis = nunchuck_buf[2]; // * 2 * 2;
  int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
  int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

  int z_button = 0;
  int c_button = 0;

  // byte nunchuck_buf[5] contains bits for z and c buttons
  // it also contains the least significant bits for the accelerometer data
  // so we have to check each bit of byte outbuf[5]
  if ((nunchuck_buf[5] >> 0) & 1)
    z_button = 1;
  if ((nunchuck_buf[5] >> 1) & 1)
    c_button = 1;

  if ((nunchuck_buf[5] >> 2) & 1)
    accel_x_axis += 2;
  if ((nunchuck_buf[5] >> 3) & 1)
    accel_x_axis += 1;

  if ((nunchuck_buf[5] >> 4) & 1)
    accel_y_axis += 2;
  if ((nunchuck_buf[5] >> 5) & 1)
    accel_y_axis += 1;

  if ((nunchuck_buf[5] >> 6) & 1)
    accel_z_axis += 2;
  if ((nunchuck_buf[5] >> 7) & 1)
    accel_z_axis += 1;

  Serial.print(i,DEC);
  Serial.print("\t");
 
  Serial.print("joy:");
  Serial.print(joy_x_axis,DEC);
  Serial.print(",");
  Serial.print(joy_y_axis, DEC);
  Serial.print("  \t");

  Serial.print("acc:");
  Serial.print(accel_x_axis, DEC);
  Serial.print(",");
  Serial.print(accel_y_axis, DEC);
  Serial.print(",");
  Serial.print(accel_z_axis, DEC);
  Serial.print("\t");

  Serial.print("but:");
  Serial.print(z_button, DEC);
  Serial.print(",");
  Serial.print(c_button, DEC);

  Serial.print("\r\n");  // newline
  i++;
}

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char nunchuk_decode_byte (char x)
{
  x = (x ^ 0x17) + 0x17;
  return x;
}

Aspect ratio en GameMaker

1. En el room, marcar "enable the use of views"
2. En View0, marcar "visible when room starts"
3. Crear un objeto llamado obj_ratio
4. En el evento CREATE, Ponerle este codigo:

///Initialize

//initialize variables
globalvar scale_multiplier;
scale_multiplier = 0;
first_run = 0; //for the alarm
globalvar HEIGHT;
globalvar WIDTH;

//initialize window size
//get width and height of screen
HEIGHT = display_get_height();
WIDTH = display_get_width();
//make view 0 fit screen
view_hview[0] = HEIGHT;
view_wview[0] = WIDTH;
view_hport[0] = HEIGHT;
view_wport[0] = WIDTH;
//make window fit screen
window_set_size(WIDTH, HEIGHT);
window_set_fullscreen(true);

//set alarm to set the game window again
alarm[5] = 5;

5. En el evento ALARM5, ponerle este código:

///Change the view[1] to fit the screen based on aspect ratio.

//get width and height of screen
test_height = HEIGHT
test_width = WIDTH
HEIGHT = display_get_height();
WIDTH = display_get_width();

//test the screen size to see if it A) changed, or B) hasn't been fully initialized
if ( ( HEIGHT != test_height ) or ( WIDTH != test_width ) or ( first_run == 0 ) )
{
first_run = 1;

//make view fit screen
view_hview[0] = HEIGHT;
view_wview[0] = WIDTH;
view_hport[0] = HEIGHT;
view_wport[0] = WIDTH;
//make window fit screen
window_set_size(WIDTH, HEIGHT);
window_set_fullscreen(true);
//make view normal again

//test the screen's aspect ratio relative to the play area's aspect ratio
if ( ( HEIGHT / view_hport[1] ) <= ( WIDTH / view_wport[1] ) )
{
/*
if the height relative to the play area's height is smaller
than the width relative to the play area's width, then
the multiplier for the screen is based on the height
this way, it stretches to fill the screen up to the height,
similar to the "Maintain Aspect Ratio" option in the
Windows module
*/
scale_multiplier = ( view_hport[0] ) / view_hport[1];
}
else
{
/*
if not, it's based on width, again like the Maintain Aspect Ratio
option in the Windows module.
*/
scale_multiplier = ( view_wport[0] ) / view_wport[1];
}

//this actually changes the play area's size
view_hport[1] = view_hport[1] * scale_multiplier;
view_wport[1] = view_wport[1] * scale_multiplier;

//this sets the position of the play area to the center of the screen

if ( ( HEIGHT / view_hport[1] ) <= ( WIDTH / view_wport[1] ) )
{
view_xport[1] = ( WIDTH / 2 ) - ( view_wport[1] / 2 );
view_yport[1] = 0;
}
else
{
view_xport[1] = 0;
view_yport[1] = ( HEIGHT / 2 ) - ( view_hport[1] / 2 );
}
}

//run the test of the first few lines again in 5 steps.
//if the screen size hasn't changed then nothing should happen
alarm[5] = 5;


6. En el evento DRAW del objeto controller, agregar al final este código

if ( view_current != 1 )  //this way we don't waste resources or have graphical errors
   {
   exit;
   }
draw_self();