Skip to content

Instantly share code, notes, and snippets.

View onishiweb's full-sized avatar

Adam Onishi onishiweb

View GitHub Profile
@onishiweb
onishiweb / uri.js
Created April 25, 2012 19:13 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
shoot: function shoot() {
//console.log("testing 1");
var video = document.getElementById('viewfinder');
var w = video.videoWidth;
var h = video.videoHeight;
var canvas = document.getElementById('capture');
canvas.width = w;
canvas.height = h;
@onishiweb
onishiweb / wp-highlight-first-2.php
Created June 17, 2012 08:22
Select the first 2 posts on a blog and use a different template to display them
<?php
// Get the WP global paged - this tells you what page number you're on
// (returns either 0 (I think) or page number)
global $paged;
// Check to see whether we've moved on to another page
if( $paged < 2):
// Set a counter
$count = 0;
endif;
?>
@onishiweb
onishiweb / feature-carousel-v1.js
Created June 28, 2012 15:24
A feature carousel I made for a client site, evolved into a circular carousel but didn't want to lose the old code...
@onishiweb
onishiweb / gist:3089751
Created July 11, 2012 11:23
Sliding sections using jQuery
slidingSections = function () {
var $container = $(".sliding-content");
var $titles = $("h3", $container);
$(".section", $container).slideUp(0).width(460).hide(); // CM: setting width here to stop the dreaded slidedown jump :)
$titles.css("cursor", "pointer").append(' <span>(click to expand)</span>');
$container.on( "click", "h3", function () {
$(".section").slideUp();
$titles.removeClass("active");
@onishiweb
onishiweb / gist:3786419
Created September 26, 2012 06:25
WordPress post meta if statement
<?php
// Perform the get meta inside the condition of the if statement,
// it will return true if there's a value, false if not,
// and if true the $meta variable will be set to the meta value
if( $meta = get_post_meta($post_id, 'meta_name', true) ):
echo $meta;
else:
// Do something else
endif;
?>
@onishiweb
onishiweb / gist:4077638
Created November 15, 2012 09:31
A for loop putting 2 posts in an li - with WordPress
<?php
// Define the arguements as you would for a WP_Query
$args = "whatever";
// Run get_posts instead of WP_Query, does a similar thing but now $slide_posts
// will contain the query results in an array...
$slide_posts = get_posts($args);
// FOR LOOP!
// 3 arguments (counter), (the test to see how many loops to run - for as long as i < the count of the array) (increment counter)
@onishiweb
onishiweb / SLide Loop
Created November 15, 2012 09:36 — forked from TobyHowarth/SLide Loop
Slide Loop
<?php
/*
Template Name: Homepage
*/
$blog = new WP_Query('category_name=articles&posts_per_page=1');
// $featured_products = new WP_Query('category_name=featured&posts_per_page=10');
// Change to:
$featured_products = get_posts('category_name=featured&posts_per_page=10');
@onishiweb
onishiweb / rem-mixin.scss
Created October 16, 2013 17:58
Rem Sass mixin (originally by @BPScott)
// Rems with pixel fallback for any property
// @author @BPScott (https://github.com/BPScott/bpscott.github.io/blob/develop/source/stylesheets/vendor/_rem.scss)
@mixin rem($property, $px-values, $baseline-px: $base-font-size) {
// Convert the baseline into rems
$baseline-rem: $baseline-px / 1rem;
// Create an empty list that we can dump values into
$rem-values: ();
@each $value in $px-values {
// If the value is zero, return 0
@onishiweb
onishiweb / simple_copyright.php
Created June 29, 2012 11:38
A simple copyright text generator for WordPress