Skip to content

Instantly share code, notes, and snippets.

View ezos86's full-sized avatar

Eric Cavazos ezos86

View GitHub Profile
@ezos86
ezos86 / jquery-api-get.js
Created July 28, 2013 18:49
Jquery .getJSON Example
function api_get (){
var url = "https://api.qpme.com/1.6/locations";
$.getJSON(url, function(data){
var size = data.length;
for(i = 0; i < size; i++){
$('#mydiv').append(data[i].address + ' - ' + data[i].name + '<br>');
console.log(data[i]);
}
});
}
@ezos86
ezos86 / example-img-hover-page.html
Last active December 20, 2015 08:19
Image Hover JS that Blows up Image
<div class="img-flat_rate" style="float:left; margin-right:20px">
<a class="img-big" href="example-big.png"><img src="example-small.png" alt="Flat Rate Example (iPhone)"/></a>
</div>
<script type="text/javascript">
$('.img-big').imgPreview();
</script>
@ezos86
ezos86 / base-api-get-request.html
Created July 28, 2013 20:44
Basic API Get Request Javascript (no jquery)
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
function api_call(){
var xhr;
// code for IE 10, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest){
@ezos86
ezos86 / base64-encoding.js
Created July 28, 2013 20:59
Base64 Encoding
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
@ezos86
ezos86 / basic-auth-api-get-call.js
Created July 28, 2013 21:38
Basic API Get Request Javascript only --> Replace username and password --> Use Base64.js file with this
function make_base_auth(user, pass) {
var tok = user + ':' + pass;
var hash = Base64.encode(tok);
return "Basic " + hash;
}
function api_call(){
var xhr;
// code for IE 10, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest){
@ezos86
ezos86 / db-input-form.php
Created August 2, 2013 07:48
This is a basic Database Insert
<!DOCTYPE>
<html>
<head>
<title></title>
</head>
<body>
<form action="db-insert.php" method="post">
<label for="firstName">First Name:</label>
<input id="firstName" name="firstName" value="" />
<br>
@ezos86
ezos86 / mail-function.php
Created August 6, 2013 05:27
PHP Mail Example
<?php
$name = $_POST['feedback-name'];
$email = $_POST['feedback-email'];
$message = $_POST['feedback-box'];
$to = 'ericc@qpme.com';
$subject = 'QPME Feedback From Customer Terminal';
$headers = 'From: website@qpme.com' . "\r\n" .
'Reply-To: webmaster@qpme.com' . "\r\n" .
@ezos86
ezos86 / jquery-ajax-submit.js
Created August 6, 2013 05:47
Jquery Ajax Submit to API Example with Complete PostBack
$.ajax({
type: 'GET',
url: reportsUrl,
beforeSend : function(xhr) {
var base64 = Base64.encode(username + ":" + password);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
contentType: 'plain/text',
xhrFields: {
withCredentials: true
@ezos86
ezos86 / scroll-fixed-nav.html
Created August 12, 2013 20:19
Nav Bar Mid-page - scroll and then fixed at top of page.
<!DOCTYPE>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<title></title>
</head>
<body>
<div style="height:3000px; position:relative; margin-top:150px; float:left;">
<span id="subnav" style="background-color:#000; height:20px; color:#fff; width:100%; float:left;">hold this</span>
</div>
@ezos86
ezos86 / jquery-no-method-error.js
Created August 19, 2013 18:42
jQuery Variable Error - Object has no method '.val()' or any other method. - it normally results from a Global variable error. Example VS below
var country = $('.countryCodeAlpha2');
var x = country.val();
console.log(x);
VS
var country = $('.countryCodeAlpha2').val;
console.log(country);