Skip to content

Instantly share code, notes, and snippets.

View knorthfield's full-sized avatar

Kris Northfield knorthfield

View GitHub Profile
@knorthfield
knorthfield / latest_tweet.php
Created March 29, 2012 10:53
Use PHP to get latest tweet for user
<?php
$twitter = json_decode(
file_get_contents(
'http://twitter.com/users/show/smythsonsdeli.json',
false,
stream_context_create(
array(
'http' => array('ignore_errors' => true)
)
)
@knorthfield
knorthfield / latest_business_status.php
Last active October 2, 2015 11:27
Get latest Facebook status for business page
<?php
$token = file_get_contents(
'https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials',
false,
stream_context_create(
array( 'http' => array('ignore_errors' => true) )
)
);
$fb = json_decode(
file_get_contents(
@knorthfield
knorthfield / live_filter.js
Created April 11, 2012 22:23
jQuery live filter
$("#filter").focus();
$("#filter").keyup(function(){
strFilter = $("#filter").val().toLowerCase();
$("ul.projects li").each(function(){
$(this).html().toLowerCase().match( strFilter ) ?
$(this).fadeIn() :
$(this).fadeOut() ;
});
});
@knorthfield
knorthfield / deploy.sh
Created April 11, 2012 22:25
rsync deployment
rsync -arvuz --delete --include .htaccess --exclude .git --exclude .gitignore --exclude deploy ~/beta.example.com/ ~/example.com/
@knorthfield
knorthfield / scrollBottom.js
Created May 10, 2012 14:56
jQuery detect if scrolled to bottom or near it
$(window).scroll(function(){
toScroll = $(document).height() - $(window).height() - 250;
if ( $(this).scrollTop() > toScroll ) {
// Do something
}
});
@knorthfield
knorthfield / googlemap.js
Created May 16, 2012 13:43
Google Maps Script
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
$(function(){
var latlng = new google.maps.LatLng(1.285121,103.852322),
map = new google.maps.Map(document.getElementById('googlemap'), {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}),
marker = new google.maps.Marker({
@knorthfield
knorthfield / parallax.html
Last active October 6, 2015 08:28
Throttled jQuery Parallax
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Parallax</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script>
$(function(){
var $scroll = ($.browser.mozilla || $.browser.msie) ? $('html') : $('body'),
@knorthfield
knorthfield / flip.html
Created September 30, 2012 22:23
CSS Flip Animation
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>CSS Flip</title>
<style type='text/css'>
/* entire container, keeps perspective */
.flip-container {
-webkit-perspective: 1000;
@knorthfield
knorthfield / page_scroll.js
Last active December 11, 2015 02:19
Single Page Nav Scroll
$('nav a').click(function(){
target = $(this).attr('href');
targetOffset = $(target).offset().top;
$('html,body').animate({ scrollTop: targetOffset }, 'slow');
return false;
});
@knorthfield
knorthfield / random_fade.js
Last active December 11, 2015 15:39
Randomly fade in elements
$('.elements')
.hide()
.each(function(index, element){
var sleepTime = Math.floor(Math.random() * 2000),
t = setTimeout(function(){
$(element).fadeTo(1000,1);
}, sleepTime);
});