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: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: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:1993909
Created March 7, 2012 15:50
jQuery: setTimeOut
setTimeout( function() {
jQuery('#loading_mask').hide();
}, 1000 );
@smonteverdi
smonteverdi / gist:1993930
Created March 7, 2012 15:54
PHP: List Files In Directory
function dirList ($directory) {
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
@smonteverdi
smonteverdi / gist:1993925
Created March 7, 2012 15:53
PHP: Get Weather From Google API
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=ADDRESS');
$information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");
echo $information[0]->attributes();
@smonteverdi
smonteverdi / gist:1993920
Created March 7, 2012 15:52
PHP: Generate Random Record
<?
// define your query
$your_query = "SELECT * FROM yourtable WHERE match1=\'yes\' AND match2<>\'yes\' AND ondate >=".date("Ymd")."";
// count the number of rows returned that match the query
$rowcnt = mysql_num_rows(mysql_query($your_query));
// generate a random number between 0 and the number of rows found (always -1)
@smonteverdi
smonteverdi / gist:1993942
Created March 7, 2012 15:56
PHP: Send Email
<?
if (isset($_REQUEST["id"]) && ($_REQUEST["id"]<>"")) {
$data1=mysql_query("SELECT * FROM your_table WHERE id=".$_REQUEST["id"]);
$data=mysql_fetch_array($data1);
$from =mymail@mydomain.com;
$to = $data["email_field"];
$user = $data["name_field"];
$subject = "Enter your subject line here"; /*or if it comes from the table*/ $subject = $data["subject_field"];
$header="From:" . $from . "\r\n " ."Reply-To:". $from ;
$body="Hello ". $user .",\n\nFirst line\n\nYour message goes here, \nbest regards,\nyour_name and such\n";
@smonteverdi
smonteverdi / gist:2050619
Created March 16, 2012 15:43
CSS: Style Placeholders
:-webkit-input-placeholder {
font-size: 12px;
font-style: italic;
color: #CCC;
}
:-moz-placeholder {
font-size: 12px;
font-style: italic;
color: #CCC;
}
@smonteverdi
smonteverdi / gist:2156440
Created March 22, 2012 05:38
WordPress: Customize password protected message
<?php
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
' . __( "This post is password protected. To view it please enter your password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';