Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / gist:8725886
Created January 31, 2014 02:58
digit_ping
/* HC-SR04 Sensor
https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696
This sketch reads a HC-SR04 ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.
The circuit:
<?php
$taxonomy = 'category';
// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator = ', ';
if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
@yratof
yratof / gist:9690234
Created March 21, 2014 16:35
Replace SVG with PNG
function supportsSVG() {
return !! document.createElementNS && !! document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect;
}
if (!supportsSVG()) {
var imgs = document.getElementsByTagName('img');
var dotSVG = /.*\.svg$/;
for (var i = 0; i !== imgs.length; ++i) {
if(imgs[i].src.match(dotSVG)) {
imgs[i].src = imgs[i].src.slice(0, -8) + 'png';
}
@yratof
yratof / timing.scss
Created April 3, 2014 14:02
Animation timings from Bourbon
// CSS cubic-bezier timing functions. Timing functions courtesy of jquery.easie (github.com/jaukia/easie)
// Timing functions are the same as demo'ed here: http://jqueryui.com/demos/effect/easing.html
// EASE IN
$ease-in-quad: cubic-bezier(0.550, 0.085, 0.680, 0.530);
$ease-in-cubic: cubic-bezier(0.550, 0.055, 0.675, 0.190);
$ease-in-quart: cubic-bezier(0.895, 0.030, 0.685, 0.220);
$ease-in-quint: cubic-bezier(0.755, 0.050, 0.855, 0.060);
$ease-in-sine: cubic-bezier(0.470, 0.000, 0.745, 0.715);
$ease-in-expo: cubic-bezier(0.950, 0.050, 0.795, 0.035);
@yratof
yratof / index.html
Last active August 29, 2015 13:58
Off-canvas navigation
<div id="container">
<div class="sidebar_left ">
<a href="#" class="close mobile-only">X</a>
<div class="inner-div">
Content Goes Here
</div>
</div>
<div class="sidebar_right mobile-only">
<a href="#" class="close mobile-only">X</a>
<div class="inner-div">
@yratof
yratof / .htaccess
Created April 24, 2014 09:52
Turn of PageSpeed in htaccess
ModPagespeed off
@yratof
yratof / index.html
Created April 29, 2014 20:48
C O N T E N T C H O R E O G R A P H Y
<div class="box">
<div class="header">header</div>
<div class="nav">nav</div>
<div class="content">content</div>
<div class="footer">footer</div>
</div>
@yratof
yratof / SQL.sql
Created May 13, 2014 23:01
Attachments in Wordpress Database
Select * from wp_posts where post_type = 'attachment';
@yratof
yratof / loop.php
Created May 13, 2014 23:28
Get the posts' attachments
<?php $args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'orderby' => 'rand',
'post_status' => null,
'post_parent' => get_the_ID(),
'post_mime_type' => 'image'
);
$images = get_children( $args );
@yratof
yratof / search.php
Last active August 29, 2015 14:01
Track Zero Search Results
<script type="text/javascript">
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else