Skip to content

Instantly share code, notes, and snippets.

@harpreetsi
harpreetsi / gist:5753153
Created June 10, 2013 22:51
php debug code
//debug code
//file_put_contents('debug.txt', $data, FILE_APPEND);
@harpreetsi
harpreetsi / gist:5705255
Created June 4, 2013 11:27
TWITTER FIELD GLOW
{
@harpreetsi
harpreetsi / shadow.html
Created June 4, 2013 10:59
background shadow for all browsers
<style>
.shadow-bringer {
width: 100px;
height: 100px;
margin: 20px auto;
padding: 5px;
background: #ffffa2;
}
@harpreetsi
harpreetsi / gist:5555913
Created May 10, 2013 17:21
mysql database backup and restore
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
input {
font-size: 68px;
}
.ltr {
direction: ltr;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Testing AJAX Upload</title>
<!-- We will load jQuery and Prototypejs to ensure that we don't have any conflicts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<!-- Also test with jQuery UI Dialog-->
<?php
$uploaddir = '/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "success";
} else {
// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
// Otherwise onSubmit event will not be fired
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ajax upload demo</title>
<!-- We will use version hosted by Google-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
<!-- Required for jQuery dialog demo-->
/**
* AJAX Upload ( http://valums.com/ajax-upload/ )
* Copyright (c) Andrew Valums
* Licensed under the MIT license
*/
(function () {
/**
* Attaches event to a dom element.
* @param {Element} el
* @param type event name
@harpreetsi
harpreetsi / gist:3069571
Created July 8, 2012 05:47
JavaScript: form validation
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
// this is a test