Skip to content

Instantly share code, notes, and snippets.

Avatar

Wayne Roddy dubrod

  • MODX
  • Inverness, FL
View GitHub Profile
@dubrod
dubrod / FQL2COUPONCODE
Created Feb 14, 2011
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.
View FQL2COUPONCODE
<?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 Apr 13, 2011
A small script to show who is the Mayor of a Foursquare Venue on your site.
View Foursquare Mayor
<?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 Apr 13, 2011
Show the 5 Recent Checkins with Name and Photo from your Gowalla Spot
View Gowalla Recent Activity Script
<?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");
View 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 Aug 30, 2011
Translate # of Twitter Followers to Discount Coupon % on osCommerce
View TWEET2COUPON
<?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 Dec 15, 2018
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 %.
View 2013 Adaptive CSS Containers
/*~~~~ 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 Jan 8, 2013
Setting Up and API in PHP for those of us awesome developers using SADO. http://www.shayanderson.com/projects/sado-php-orm.htm
View SADO API
<?
//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 Dec 13, 2015
Switch MODX Nav from <ul> to <select> when mobile device detected.
View MODX Nav Switch
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 May 12, 2016
A simple mobile device detector in PHP . If $mobile_browser == true ....
View Mobile Device Detect
<?
$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 Apr 30, 2013
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
View gist:5488995
// 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;
You can’t perform that action at this time.