Skip to content

Instantly share code, notes, and snippets.

@zvineyard
zvineyard / gist:3147253
Created July 19, 2012 22:18
PHP: file_get_contents() HTTP Login
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
@zvineyard
zvineyard / gist:3145677
Created July 19, 2012 17:59
Bash: Send an Email Attachment from Command line with mailx
#!/bin/bash
uuencode /file.csv /file.csv | mail x -r "[email protected]" -s "Subject" [email protected]
@zvineyard
zvineyard / gist:3106540
Created July 13, 2012 18:34
Android: Simulate Slow Internet Response
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
@zvineyard
zvineyard / gist:3084842
Created July 10, 2012 17:19
Android: Get Spinner Value
final Spinner sp = (Spinner) findViewById(R.id.state);
String state = sp.getSelectedItem().toString();
@zvineyard
zvineyard / controller.php
Created July 9, 2012 20:03
CodeIgniter: Add blank value to form_dropdown() and validate
$this->form_validation->set_rules('test', 'Test Field', 'required');
@zvineyard
zvineyard / gist:3035925
Created July 2, 2012 21:48
JavaScript: Disable Submit Button Upon Form Submission
<form name="form_name" action="" method="post" onsubmit="document.getElementById('btn_submit').disabled = 1;">
<input type="submit" name="btn_submit" value="Submit" class="btn" id="btn_submit" />
</form>
@zvineyard
zvineyard / gist:2984509
Created June 24, 2012 19:08
CSS: Reset
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
@zvineyard
zvineyard / gist:2968624
Created June 21, 2012 21:26
PHP: Array of US States
$state_list = array(
'AL'=>"Alabama",
'AK'=>"Alaska",
'AZ'=>"Arizona",
'AR'=>"Arkansas",
'CA'=>"California",
'CO'=>"Colorado",
'CT'=>"Connecticut",
'DE'=>"Delaware",
'DC'=>"District Of Columbia",
@zvineyard
zvineyard / gist:2966002
Created June 21, 2012 14:18
PHP: Convert File Timestamp to Unix Timestamp
function file_to_unix_time($file_time,$round=true) {
if ($round) {
return round(($file_time - 116444736000000000) / 10000000);
}
return ($file_time - 116444736000000000) / 10000000;
}
@zvineyard
zvineyard / gist:2955326
Created June 19, 2012 17:07
TypoScript: Page ID Conditional
[globalVar = TSFE:id = 76]
page.includeCSS {
file1 = fileadmin/templates/css/style.css
}
[end]