Skip to content

Instantly share code, notes, and snippets.

View smonteverdi's full-sized avatar

Sean Monteverdi smonteverdi

View GitHub Profile
@smonteverdi
smonteverdi / gist:1993919
Created March 7, 2012 15:52
PHP: Generate Password
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength >= 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength >= 2) {
$vowels .= "AEUY";
}
if ($strength >= 4) {
@smonteverdi
smonteverdi / gist:1993918
Created March 7, 2012 15:51
PHP: Connect to Database mysql way
<?php
$username = "your_name";
$password = "your_password";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
@smonteverdi
smonteverdi / gist:1993913
Created March 7, 2012 15:50
PHP: Check if user is logged in
functions.php
<?php
function loggedIn(){
//Session logged is set if the user is logged in
//set it on 1 if the user has successfully logged in
//if it wasn't set create a login form
if(!$_SESSION['loggd']){
echo'<form action="checkLogin.php" method="post">
<p>
@smonteverdi
smonteverdi / gist:1993909
Created March 7, 2012 15:50
jQuery: setTimeOut
setTimeout( function() {
jQuery('#loading_mask').hide();
}, 1000 );
@smonteverdi
smonteverdi / gist:1993903
Created March 7, 2012 15:49
jQuery: Accordion show/hide
var dd = $('dd');
dd.filter(':nth-child(n+4)').addClass('hide');
$('dt').on('click',function(){
$(this)
.next()
.slideDown('fast')
.siblings('dd')
.slideUp('fast');
});
@smonteverdi
smonteverdi / gist:1993896
Created March 7, 2012 15:48
CSS: Text Field Rounded and Inset Shadow
input {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
padding: 8px;
border: 0;
-webkit-box-shadow: inset 1px 1px 4px rgba(0,0,0,0.6);
-moz-box-shadow: inset 1px 1px 4px rgba(0,0,0,0.6);
box-shadow: inset 1px 1px 4px rgba(0,0,0,0.6);
}
@smonteverdi
smonteverdi / gist:1993884
Created March 7, 2012 15:46
CSS: Inset Box
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7) inset, 0 1px 0 rgba(255, 255, 255, .1);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7) inset, 0 1px 0 rgba(255, 255, 255, .1);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7) inset, 0 1px 0 rgba(255, 255, 255, .1);
@smonteverdi
smonteverdi / gist:1993873
Created March 7, 2012 15:43
CSS: Hide Text
.hide-text { text-indent: 100%; white-space: nowrap; overflow: hidden; font:0/0; text-shadow: none; }
@smonteverdi
smonteverdi / gist:1993869
Created March 7, 2012 15:42
WordPress: Show custom field outside of loop
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'MyField', true);
?>
@smonteverdi
smonteverdi / gist:1993865
Created March 7, 2012 15:41
WordPress: Security mods
// Security checks
function wrong_login() {
return 'Wrong username or password.';
}
add_filter('login_errors', 'wrong_login');
function remove_version() {
return '';
}
add_filter('the_generator', 'remove_version');