Si, la verdad es que funciona incluso mejor de lo que me esperaba, de ahí que crea que está todo correcto.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú#include <unistd.h>
main(){
pipeline("/usr/bin/yes", "/bin/more");
}
int pipeline(char *proc1, char *proc2){
int fd[2];
pipe(fd);
if (fork()!=0){
close(fd[0]); // No lo necesitamos aqui
close(1); // Cierra la salida estandar
dup(fd[1]);
close(fd[1]); // No lo necesitamos
execl(proc1, proc1, 0);
}
else{
close(fd[1]); // No lo necesitamos
close(0); // Cierra la entrada estandar
dup(fd[0]);
close(fd[0]); // No lo necesitamos
execl(proc2, proc2, 0);
}
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//ConexionSQLiteHelper conn=new ConexionSQLiteHelper(this,"bdTiendas",null,1);
}
public void onClick(View view){
Intent nueva_ventana = new Intent(MainActivity.this, registrarTienda.class);
startActivity(nueva_ventana);
}
}
public class Utilidades {
public static final String TABLA_TIENDA="tienda";
public static final String CampoNumeroTienda="numTienda";
public static final String CampoNombreTienda="nombre";
public static final String CampoMuelleFrio="muelleFrio";
public static final String CampoMuelleFruta="muelleFruta";
public static final String CampoMuelleSeco="muelleSeco";
public static final String CampoDireccion="direccion";
public static final String CampoTelefono="telefono";
public static final String CREAR_TABLA_TIENDA="CREATE TABLE"+TABLA_TIENDA+"("+CampoNumeroTienda+" INTEGER, "+CampoNombreTienda+
" TEXT,"+CampoMuelleFrio+" INTEGER, "+CampoMuelleFruta+" INTEGER,"+CampoMuelleSeco+" INTEGER,"+
CampoDireccion+" TEXT,"+CampoTelefono+" TEXT)";
public class Tienda {
private Integer numTienda;
private String nombre;
private Integer muelleFrio;
private Integer muelleFruta;
private Integer muelleSeco;
private String direccion;
private String telefono;
public Integer getNumTienda() {
return numTienda;
}
public void setNumTienda(Integer numTienda) {
this.numTienda = numTienda;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Integer getMuelleFrio() {
return muelleFrio;
}
public void setMuelleFrio(Integer muelleFrio) {
this.muelleFrio = muelleFrio;
}
public Integer getMuelleFruta() {
return muelleFruta;
}
public void setMuelleFruta(Integer muelleFruta) {
this.muelleFruta = muelleFruta;
}
public Integer getMuelleSeco() {
return muelleSeco;
}
public void setMuelleSeco(Integer muelleSeco) {
this.muelleSeco = muelleSeco;
}
public String getDireccion() {
return direccion;
}
public void setDireccion(String direccion) {
this.direccion = direccion;
}
public String getTelefono() {
return telefono;
}
public void setTelefono(String telefono) {
this.telefono = telefono;
}
public Tienda(Integer numTienda, String nombre, Integer muelleFrio, Integer muelleFruta, Integer muelleSeco, String direccion, String telefono) {
this.numTienda = numTienda;
this.nombre = nombre;
this.muelleFrio = muelleFrio;
this.muelleFruta = muelleFruta;
this.muelleSeco = muelleSeco;
this.direccion = direccion;
this.telefono = telefono;
}
}
public class ConexionSQLiteHelper extends SQLiteOpenHelper {
public ConexionSQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(Utilidades.CREAR_TABLA_TIENDA);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS tabla");
onCreate(db);
}
}
public class registrarTienda extends AppCompatActivity {
EditText nombre_tienda,numero_tienda,muelle_frio,muelle_fruta
,muelle_seco,direccion,telf;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registrar_tienda);
nombre_tienda=(EditText) findViewById(R.id.nombreTienda);
numero_tienda=(EditText) findViewById(R.id.numeroTienda);
muelle_frio=(EditText) findViewById(R.id.muelleFrio);
muelle_fruta=(EditText) findViewById(R.id.muelleFruta);
muelle_seco=(EditText) findViewById(R.id.muelleseco);
direccion=(EditText) findViewById(R.id.direccionTienda);
telf=(EditText) findViewById(R.id.numTelfTienda);
}
public void onClick(View view){
registroTienda();
}
private void registroTienda() {
ConexionSQLiteHelper conn=new ConexionSQLiteHelper(this,"bdTiendas",null,1);
SQLiteDatabase db=conn.getWritableDatabase(); //PROBLEMA
ContentValues values=new ContentValues();
values.put(Utilidades.CampoNumeroTienda,numero_tienda.getText().toString());
values.put(Utilidades.CampoNombreTienda ,nombre_tienda.getText().toString());
values.put(Utilidades.CampoMuelleFrio,muelle_frio.getText().toString());
values.put(Utilidades.CampoMuelleFruta,muelle_fruta.getText().toString());
values.put(Utilidades.CampoMuelleSeco,muelle_seco.getText().toString());
values.put(Utilidades.CampoDireccion,direccion.getText().toString());
values.put(Utilidades.CampoTelefono,telf.getText().toString());
// Long idResultante=db.insert(Utilidades.TABLA_TIENDA,Utilidades.CampoNombreTienda,values);
// Toast.makeText(getApplicationContext(),"Tienda: "+idResultante+" agregada",Toast.LENGTH_SHORT).show();
}
}
$(document).ready(function() {
// Creamos un contexto 2d de nuestro canvas
var canvas = $("#snake")[0];
var context = canvas.getContext("2d");
var width = $("#snake").width();
var height = $("#snake").height();
var cellWidth = 10;
var d;
var food;
var score;
var level = 6; // 1 El nivel más lento, 10 el nivel más rápido.
// contiene el listado de celdas por donde pasa la serpiente
var snake;
// El juego tiene la dirección "right" por defecto y se ejecuta la función paint
// dependiendo el nivel que hayas configurado arriba
function init()
{
d = "right";
createSnake();
createFood();
score = 0;
if(typeof gameLoop != "undefined") {
clearInterval(gameLoop);
}
gameLoop = setInterval(paint, 500 / level);
}
init();
// Creamos la serpiente
function createSnake()
{
var length = 5;
snake = [];
for(var i = length - 1; i >= 0; i--)
{
snake.push({ x: i, y: 0 });
}
}
//Creamos el recuado que tiene que comerse la serpiente
function createFood()
{
food = {
x: Math.round(Math.random() * (width - cellWidth) / cellWidth),
y: Math.round(Math.random() * (height - cellWidth) / cellWidth),
};
}
//Dibujamos la serpiente
function paint()
{
context.fillStyle = "#ccc";
context.fillRect(0, 0, width, height);
context.strokeStyle = 'black';
context.strokeRect(0, 0, width, height);
var nx = snake[0].x;
var ny = snake[0].y;
if (d == "right") {
nx++;
} else if (d == "left") {
nx--;
} else if (d == "up") {
ny--;
} else if (d == "down") {
ny++;
}
if (nx == -1 || nx == width / cellWidth || ny == -1 || ny == height / cellWidth || checkCollision(nx, ny, snake)) {
init();
return;
}
if(nx == food.x && ny == food.y) {
var tail = {
x: nx,
y: ny
function pla();
};
score++;
createFood();
} else {
var tail = snake.pop();
tail.x = nx;
tail.y = ny;
}
snake.unshift(tail);
for(var i = 0; i < snake.length; i++) {
var c = snake[i];
paintCell(c.x, c.y);
}
paintCell(food.x, food.y);
var scoreText = "Score: " + score;
context.fillText(scoreText, 5, height - 5);
}
//Pintamos la celda
function paintCell(x, y)
{
context.fillStyle = "red";
context.fillRect(x * cellWidth, y * cellWidth, cellWidth, cellWidth);
context.strokeStyle = 'white';
context.strokeRect(x * cellWidth, y * cellWidth, cellWidth, cellWidth);
}
//Verificiamos si hubo alguna colisión (si la hubo el juego se reinicia)
function checkCollision(x, y, array)
{
for(var i = 0; i < array.length; i++)
{
if(array[i].x == x && array[i].y == y) {
return true;
}
}
return false;
}
// Capturamos la pulsación de las teclas
$(document).keydown(function(e) {
var key = e.which;
if (key == "37" && d != "right") {
d = "left";
} else if (key == "38" && d != "down") {
d = "up";
} else if (key == "39" && d != "left") {
d = "right";
} else if (key == "40" && d != "up") {
d = "down";
}
});
});
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="serpiente.js" type="text/javascript"></script>
<style>
.game
{
margin: 0 auto;
width: 450px;
}
</style>
</head>
<body>
<div class="game">
<canvas id="snake" width="450" height="450"></canvas>
</div>
<audio controls autoplay loop>
<source src="horse.ogg" type="audio/ogg" >
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
<html>
<link rel="stylesheet" type="text/css" href="css.css">
<body>
<form action="" method="post">
<table border="1" cellpadding="5" cellspacing="0" align="center">
<tr><td colspan="2" align="center">ACCESO SIGUIENTE PRUEBA</td></tr>
<tr><td>Usuario:</td> <td><input type="text" name="user" autocomplete="off" /></td></tr>
<tr><td>Contrasñea:</td> <td><input type="password" name="pass" /></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="enviar" value="Enviar" /></td></tr>
</table>
</form>
<h1>
Prueba 8</h1>
<p> Usuario suma de 1+1 y contraseña resta de 10-8</p>
</body>
</html>
<?php
if(($_POST)){
# Aqui definimos el usuario y password
# Puedes cambiar el usuario y clave x lo q sea
$usuario = '2';
$clave = '2';
# Aqui compruebo q los datos(usuario y contraseña) ingresados sean igual a lo que eh definido
# Y si son correcto los datos redireciona al enlace de tu sitio Autorizado
# En que caso que no sean correcto los datos recirecciona al enlace de Error de Datos Ingresados
if(trim((($_POST['user'])==$usuario && trim($_POST['pass'])==$clave))) {
header('Location: index2.html');
}else{
header('Location: Error.html');
}
}
?>