Skip to content

Instantly share code, notes, and snippets.

View maccath's full-sized avatar
👩‍💻
Always Coding

Katy Ereira maccath

👩‍💻
Always Coding
View GitHub Profile
@maccath
maccath / gist:5252923
Created March 27, 2013 09:20
iPhone/iPod/iPad-only functionality
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
// iPhone/iPod/iPad-only functionality here
}
@maccath
maccath / nvl_plsql_oracle_examples.sql
Created February 14, 2013 16:19
Examples for the usage of Oracle/PLSQL's NVL() function for substitution of NULL values
# ORACLE/PLSQL - NVL(A, B) EXAMPLES
# If A IS NULL substitute with B
# Example 1. if table b contains values that over-write values in table a
SELECT NVL(b.name, a.name) AS name FROM a left join b on a.id = b.id;
# Example 2. to replace NULL values with an alternative placeholder value
SELECT NVL(a.name, 'Unnamed') AS name FROM a;
@maccath
maccath / jqgrid-livefilter.js
Created December 13, 2012 15:34
Live filtering in jqGrid. Povides a search box at the top of your grid allowing you to filter the rows on the current page by your input value. If your input matches any data in any of the cells of a particular row, that row will be shown whilst others will be hidden. Matches against all columns dynamically.
$(function() {
var $grid = $('#yourGridId'); // @todo: Insert your grid selector
var gridData;
var rowIds;
$grid.jqGrid({
// @todo: Insert your grid configuration
loadComplete : function (data) {
gridData = $grid.jqGrid('getRowData');
@maccath
maccath / gist:3981205
Created October 30, 2012 16:09
Split PDF to individual pages using FPDI and FPDF
<?php
/**
* Split PDF file
*
* <p>Split all of the pages from a larger PDF files into
* single-page PDF files.</p>
*
* @package FPDF required http://www.fpdf.org/
* @package FPDI required http://www.setasign.de/products/pdf-php-solutions/fpdi/
@maccath
maccath / auto-increment.mysql
Created September 9, 2012 20:33
Manually automatically increment a column in MySQL
/**
* Manually automatically increment a column in MySQL
*
* Ok, so a little introduction is warranted here, because I don't just mean setting
* a column as 'AUTO_INCREMENT'.
*
* I am currently working on a project where a user can sort the records however
* they like. The order is determined by a column I have named 'sort'. When they
* input the data, it was random, but they wanted it to sort alphabetically by
* default, and rearrange from there. This quick script sets the 'sort' column to an
@maccath
maccath / tweet.php
Created August 25, 2012 22:16
Get a user's latest tweet with cURL; no API key needed
<?php
/**
* Return a user's latest tweet using cURL
*
* @param string $username The username for whom you wish to fetch a tweet
* @return mixed The tweet if it exists, NULL otherwise
*/
function latest_tweet($username) {
$url = 'http://search.twitter.com/search.json?from='.$username;