Skip to content

Instantly share code, notes, and snippets.

@MadaraUchiha
MadaraUchiha / form_class.php
Created April 27, 2012 16:23
Form class - Generate valid good looking forms with PHP.
<?php
namespace Forms;
/**
* This file is supposed to give a good way of generating forms programmatically with PHP.
*/
/*
* WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
* -----------------------------------------------------------------------------------------------------------
* None of the strings you see in the following classes are escaped/secured against any kind of
@ebidel
ebidel / handle_file_upload.php
Created April 18, 2012 03:23
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@kinlane
kinlane / uploadFile.php
Created April 14, 2012 19:20
IDrive - EVS - REST API - uploadFile
// Upload a File
$uid = "[your IDrive user name]";
$pwd = "[your IDrive user password]";
$localFile = "[path to your local file just uploaded or otherwise]";
$crtpath = "[path to your local cert]";
// file
$PostFields = array(
'file' => '@' . $localFile . '',
'uid' => $uid,
<?php
curl_setopt($ch, CURLOPT_URL, '<IDRIVE SERVER LOCATION>/evs/downloadEvent');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$body = 'uid=' . '<IDRIVE USER ID>'. '&pwd=' . '<IDRIVE USER PASSWORD>'. '&month=' . '<MONTH OF EVENTS>'. '&year=' . '<YEAR OF EVENTS>'. '&eventid=' . '<ID OF EVENT>';
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
<?php
curl_setopt($ch, CURLOPT_URL, '<IDRIVE SERVER LOCATION>/evs/browseFolder');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$body = 'uid=' . '<IDRIVE USER ID>'. '&pwd=' . '<IDRIVE USER PASSWORD>'. '&p=' . '<PATH TO FOLDER ON THE IDRIVE SERVER TO BROWSE>';
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
@gudbergur
gudbergur / README.markdown
Created February 19, 2012 23:49
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@mikejolley
mikejolley / gist:1597957
Created January 12, 2012 01:40
WooCommerce - Replace '' with 'Call for price' when price is left blank
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
function custom_call_for_price() {
return 'Call for price';
}
@amereservant
amereservant / auth.php
Created October 22, 2011 23:10
phpFlickr API Detailed Example HowTo
<?php
/* Last updated with phpFlickr 3.1
*
* Edit these variables to reflect the values you need. $default_redirect
* and $permissions are only important if you are linking here instead of
* using phpFlickr::auth() from another page or if you set the remember_uri
* argument to false.
*/
// Include configuration file
@innotekservices
innotekservices / jquery.spin.js
Created October 16, 2011 02:39
jQuery Plugin for Spin.js
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
@mjuhl
mjuhl / progress.php
Created October 12, 2011 18:19
PHP Output Buffering/JavaScript/CSS Transition Progress Bar Experiment
<?php
/* For AJAX, if frustrated, try the following (see http://www.php.net/manual/en/function.flush.php#91556):
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
*/
ob_start();
set_time_limit(0); // for scripts that run really long
function force_flush ($add_whitespace = TRUE) {