This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.validator.addMethod('require-one', function (value) { | |
return $('.require-one:checked').size() > 0; }, 'Please check at least one box.'); | |
var checkboxes = $('.require-one'); | |
var checkbox_names = $.map(checkboxes, function(e,i) { return $(e).attr("name")}).join(" "); | |
$("#itemForm").validate({ | |
groups: { checks: checkbox_names }, | |
errorPlacement: function(error, element) { | |
if (element.attr("type") == "checkbox") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fecha = "2013-11-23"; | |
echo date("Y/m/t", strtotime($fecha)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { | |
// $.getJSON( sSource, aoData, function (json) { | |
// if(json.error == 'session_out'){ | |
// document.location.href='index.php?msg=session_out'; | |
// } else { | |
// fnCallback(json) | |
// } | |
// }); | |
$.post(sSource, aoData, function(json) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onCreate (Bundle savedInstanceState) | |
{ | |
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); | |
StrictMode.setThreadPolicy(policy); | |
super.onCreate(savedInstanceState); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage( getBaseContext().getPackageName() ); | |
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |
startActivity(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
STUFF( | |
( | |
SELECT | |
',' + RTRIM(LTRIM(TELEFONO)) | |
FROM CLIENTE | |
WHERE CLIENTE = '10655' | |
ORDER BY TELEFONO FOR xml path('') | |
) | |
, 1, 1, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Obtener el array | |
$myarray = glob("*.*"); | |
// Ordenar por fecha ascendente | |
usort($myarray, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Obtener registros de la tabla con fecha superior a hace tres meses | |
SELECT * FROM tabla WHERE fecha >= DATE_ADD(NOW(),INTERVAL -3 MONTH) | |
// De otro modo: | |
SELECT * FROM tabla WHERE fecha >= (NOW() + INTERVAL -3 MONTH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = $_FILES['image']['name']; | |
$ext = pathinfo($path, PATHINFO_EXTENSION); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tomar una aguja de 1cm y un papel con líneas paralelas a 2cm | |
// Lanzar la aguja sobre el papel, cada vez que la aguja corta una linea | |
// cuenta como un acierto | |
// pi (aprox) = intentos / aciertos | |
import java.util.Random; | |
import java.util.Scanner; | |
public class BuffonPiEstimation | |
{ |