Skip to content

Instantly share code, notes, and snippets.

View alexanderjsingleton's full-sized avatar

Alex Singleton alexanderjsingleton

View GitHub Profile
@alexanderjsingleton
alexanderjsingleton / shortcodes.php
Last active December 30, 2015 17:19
Retooling a php hash-table to accommodate over 72 [social-media buttons](http://tomswebspace.com/round-social-media-icons/).
//Member social
function member_social($atts, $content = null)
{
extract(shortcode_atts(array("twitter" => "", "facebook" => "", "github" => "", "linkedin" => ""), $atts));
$html = "\n".'<nav class="team-social text-center">
<a target="_blank" href="http://twitter.com/'.$twitter.'"><img title="Twitter" alt="renova" src="'.get_stylesheet_directory_uri().'/images/social/cool/round/twitter.png"></a>
<a target="_blank" href="http://facebook.com/'.$facebook.'"><img title="Facebook" alt="renova" src="'.get_stylesheet_directory_uri().'/images/social/cool//round/facebook.png"></a>
<a target="_blank" href="http://linkedin.com/in/'.$linkedin.'"><img title="LinkedIn" alt="renova" src="'.get_stylesheet_directory_uri().'/images/social/cool//round/linkedin.png"></a>
<a target="_blank" href="http://github.com/'.$github.'"><img title="GitHub" alt="renova" src="'.get_stylesheet_directory_uri().'/images/social/cool//round/github
@alexanderjsingleton
alexanderjsingleton / oracle_regex_example.sql
Created February 7, 2016 02:25
Oracle SQL does indeed handle regex.
SELECT invoice_id,
invoice_number
FROM ap.invoices
WHERE REGEXP_LIKE (invoice_number, '^P(*)');
@alexanderjsingleton
alexanderjsingleton / gist:54963903a2b130ecf3c4
Created February 18, 2016 15:49
[That feeling when I land a big-ass query on the first try...](http://imgur.com/9VQyUb1)
SELECT CONCAT(CONCAT(CONCAT(CONCAT(city, ' '),STATE),' '),zip) AS "All together with Concat"
FROM student.zipcode;
@alexanderjsingleton
alexanderjsingleton / case_statement.sql
Last active February 19, 2016 23:46
A SQL solution using a CASE statement.
SELECT * FROM (
SELECT student_id,
salutation,
CASE
WHEN salutation IN('Dr.') THEN 'Doctor'
END AS NewSalutation
FROM student.student
)
WHERE NewSalutation IS NOT NULL;
@alexanderjsingleton
alexanderjsingleton / quadratic_solver.sql
Last active February 24, 2016 16:50
In case you needed SQL for a quadratic-equation solver.
ALTER SESSION
SET NLS_NUMERIC_CHARACTERS='. ';
SELECT 'Not a quadratic equation.' AS "Answer 1", '0' AS "Answer 2"
FROM dual
WHERE &&A = 0
UNION
SELECT 'x = ' || to_char(-&&B/2/&A) AS "Answer 1", '0' AS "Answer 2"
FROM dual
WHERE &A != 0
@alexanderjsingleton
alexanderjsingleton / renato-markdown-converter.gapps
Created February 29, 2016 04:05
Renato's script for converting GoogleDoc documentation to Markdown.
/*
Usage:
Adding this script to your doc:
- Tools > Script Manager > New
- Select "Blank Project", then paste this code in and save.
Running the script:
- Tools > Script Manager
- Select "ConvertToMarkdown" function.
- Click Run button.
- Converted doc will be mailed to you. Subject will be "[MARKDOWN_MAKER]...".
@alexanderjsingleton
alexanderjsingleton / manual-form.php
Last active March 14, 2016 14:00
Learn php the Hard Way.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="BucephalusDev-Favicon.png">
@alexanderjsingleton
alexanderjsingleton / plsql_regexp.sql
Last active May 5, 2016 14:40
How to avoid whitespace with RegEx when concatenating multiple-columns in Oracle PL/SQL (REGEXP_REPLACE)
CONNECT ap/ap;
SET SERVEROUTPUT ON
declare
min_invoice_total ap.invoices.invoice_total%TYPE;
max_invoice_total ap.invoices.invoice_total%TYPE;
begin
SELECT MIN(invoice_total), MAX(invoice_total) INTO min_invoice_total,max_invoice_total
FROM ap.invoices;
DBMS_OUTPUT.put_line(REGEXP_REPLACE('The minimum invoice total is' || to_char(min_invoice_total, '$999,999.00') || ' while the maximum output total is ' || to_char(max_invoice_total, '$999,999.00') || '.', ' +', ' '));
end;
@alexanderjsingleton
alexanderjsingleton / oracleSQL_robocop.sql
Created May 5, 2016 23:45
"DROP 'EM, CREEP!" -RoboCob | A SQL-snipper to clear/purge all table-data.
SELECT 'drop table '||table_name||' cascade constraints;' FROM user_tables;
@alexanderjsingleton
alexanderjsingleton / plsql.sql
Last active May 13, 2016 22:21
A simple Oracle PL/SQL statement provided for [my blog-post on databases](https://www.alexanderjsingleton.com/event-horizon-data-centric-future)
-- An Oracle PL/SQL example for my blog-post:
CONNECT ap/ap;
SET SERVEROUTPUT ON
declare
min_invoice_total ap.invoices.invoice_total%TYPE;
max_invoice_total ap.invoices.invoice_total%TYPE;
begin
SELECT MIN(invoice_total), MAX(invoice_total) INTO min_invoice_total,max_invoice_total
FROM ap.invoices;