Skip to content

Instantly share code, notes, and snippets.

View dubrod's full-sized avatar

Wayne Roddy dubrod

View GitHub Profile
@dubrod
dubrod / FQL2COUPONCODE
Created February 14, 2011 18:54
Using the new FQL (Facebook) we pull # of Likes of a company page, make it a %, and insert it into osCommerce for a Coupon Code.
<?php
// must have http://addons.oscommerce.com/info/4269 installed in your osCommerce
$fb_data = json_decode(file_get_contents("https://graph.facebook.com/ACCESS-TOKEN-HERE"), true);
// ACCESS TOKEN FOR YOUR PAGE OR PROFILE
// See http://developers.facebook.com/docs/reference/api - Once a user has granted your application the "manage_pages" permission, the "accounts" connection will yield an additional access_token property for every page administrated by the current user.
// used for debugging/install
// print "<pre>";
@dubrod
dubrod / Foursquare Mayor
Created April 13, 2011 13:21
A small script to show who is the Mayor of a Foursquare Venue on your site.
<?php
//main function
function foursquare_spotter() {
//set SpotID and Oauth Token - https://foursquare.com/oauth/
$spot_id = 311661; // just change this # to your venue # in the foursquare URL
$oauth_token = 123456789; // just change this # to your Oauth Token
if ($spot_id != "") {
@dubrod
dubrod / Gowalla Recent Activity Script
Created April 13, 2011 13:27
Show the 5 Recent Checkins with Name and Photo from your Gowalla Spot
<?php
function nicetime($date)
{
if(empty($date)) {
return "No date provided";
}
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
@dubrod
dubrod / Facebook Feed Trim
Created June 17, 2011 15:50
Facebook Feed Trim
<?php
function facebook_feed() {
$token = "XXXXXX";
$fb_id = "XXXXXX"; // the number in your Facebook URL
$json = json_decode(file_get_contents("https://graph.facebook.com/$fb_id/feed?access_token=$token"), true);
// only grab 1st
@dubrod
dubrod / TWEET2COUPON
Created August 30, 2011 14:18
Translate # of Twitter Followers to Discount Coupon % on osCommerce
<?php
$tweet_data = json_decode(file_get_contents("http://api.twitter.com/1/users/show.json?screen_name=YOURTWITTERNAME"), true);
// display tweet data array ( just to show you i know what i'm doing =] )
//print "<pre>";
//print_r($tweet_data);
//print "</pre>";
@dubrod
dubrod / 2013 Adaptive CSS Containers
Last active December 15, 2018 19:01
2013 Adaptive CSS Containers Snippet. From 1600+ to Mobile. This snippet will keep a nice margin on the sides of your container for browser size most used in 2012. It's not a Responsive Snippet, that would be using %.
/*~~~~ CONTAINERS December 2013 - http://www.w3counter.com/globalstats.php ~~~~*/
/* 1600x900 4.09% */
.container{
margin: 0 auto;
padding:0;
height:auto;
width:1410px; /* 3 Columns would be 470px */
}
/* 1440x900 5.26% */
@media (max-width: 1440px){ .container{width: 1230px; /* 3 Columns would be 410px */ } }
@dubrod
dubrod / SADO API
Created January 8, 2013 15:02
Setting Up and API in PHP for those of us awesome developers using SADO. http://www.shayanderson.com/projects/sado-php-orm.htm
<?
//bootstrap
require_once 'lib/Sado/sado.bootstrap.php';
//pre-qualify
if(function_exists($_GET['method'])){
$_GET['method']();
}
//methods
@dubrod
dubrod / MODX Nav Switch
Last active December 13, 2015 19:29
Switch MODX Nav from <ul> to <select> when mobile device detected.
Change Nav UL to Select when Mobile.
System Settings: Turn off resource and snippet caching. cacheable default is none. no pages can be cached.
1. add mobile_device_detect.php to the root folder
2. make sure jquery is called at the top of every page
@dubrod
dubrod / Mobile Device Detect
Last active January 5, 2023 16:33
A simple mobile device detector in PHP . If $mobile_browser == true ....
<?
$mobile_browser = false; // set mobile browser as false till we can prove otherwise
$user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed
$accept = $_SERVER['HTTP_ACCEPT']; // get the content accept value - this should be cleaned to ensure no nefarious input gets executed
switch(true){ // using a switch against the following statements which could return true is more efficient than the previous method of using if statements
case (preg_match('/ipad/i',$user_agent)); // we find the word ipad in the user agent
$mobile_browser = false; // mobile browser is either true or false depending on the setting of ipad when calling the function
$status = 'Apple iPad';
@dubrod
dubrod / gist:5488995
Created April 30, 2013 14:12
Prototype slider js file. Used in Magento 1.7 - Based on http://www.tomdoyletalk.com/simple-gallery/ - BUT I changed line 20 duration to 0 so you don't have that stack issue
// set the starting image.
var i = 0;
// The array of div names which will hold the images.
var image_slide = new Array('image-1', 'image-2', 'image-3');
// The number of images in the array.
var NumOfImages = image_slide.length;