Skip to content

Instantly share code, notes, and snippets.

View ptasker's full-sized avatar
:fishsticks:

Peter Tasker ptasker

:fishsticks:
View GitHub Profile
@ptasker
ptasker / gist:4025029
Created November 6, 2012 14:29
Centos cPanel log locations
Apache Error Log - /usr/local/apache/logs/error_log
cPanel Error Log - /usr/local/cpanel/logs/error_log
MySQL Error Log - /var/lib/mysql/FULLSERVERHOSTNAME.err
Exim Main Log - /var/log/exim_mainlog
FTP ERROR LOG - /var/log/messages
@ptasker
ptasker / gist:4040329
Created November 8, 2012 17:45
Facebook JS SDK API - FQL Query
//The following FQL get's events attached to a page. But it could be any FQL query.
var Q = "SELECT eid, name, description, pic_big, start_time, end_time, location FROM event WHERE creator = PAGE_ID AND eid IN (SELECT eid FROM event_member WHERE uid = PAGE_ID)";
FB.api("/fql?q=" + encodeURIComponent(Q), function(response) {
console.log(response);
}, 'get', {
access_token: 'GENERATED_APP_ACCESS_TOKEN'
});
@ptasker
ptasker / gist:4041640
Created November 8, 2012 21:12
Facebook JS SDK API - Post Image to Feed
function share_image(img_url, text) {
//Check to see if the user has authenticated the App.
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//If you want the user's Facebook ID or their access token, this is how you get them.
var uid = response.authResponse.userID;
var access_token = response.authResponse.accessToken;
do_api_share(access_token, img_url, text);
@ptasker
ptasker / gist:4060263
Created November 12, 2012 16:19
Facebook - Redirect app to tab
<?php
if ( isset( $_SERVER['HTTP_ORIGIN'] ) && stristr( $_SERVER['HTTP_ORIGIN'], 'apps.facebook.com' ) ) {
echo("<script> top.location.href='" . c_i( 'fb_tab_url' ) . "'</script>");
}
@ptasker
ptasker / gist:4162223
Created November 28, 2012 16:08
GA Track Social
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
FB.Event.subscribe('edge.remove', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);
});
FB.Event.subscribe('message.send', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);
@ptasker
ptasker / gist:4208792
Created December 4, 2012 21:19
Detect French browser lang
<?php
/**
@uses CodeIgniter 2.1
Grab the user's language from the HTTP_ACCEPT_LANGUAGE string.
*/
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
@ptasker
ptasker / gist:4979155
Created February 18, 2013 17:44
POSIX commands that are helpful
Get IP add of server Ubuntu 12.04 - ifconfig eth0 | grep inet | awk '{ print $2 }'
@ptasker
ptasker / gist:5164901
Created March 14, 2013 20:24
PHP Twitter Image grabber
<?php
if( isset($_GET['username']) ){
$user = mysql_real_escape_string( strip_tags( $_GET['username'] ));
$ext = '';
echo "<p>";
for( $i = 1; $i<100; $i++ ){
if( $i>1 ){
@ptasker
ptasker / gist:5190149
Created March 18, 2013 19:35
SVN WebDAV create new user
sudo htpasswd /etc/subversion/passwd second_user_name
@ptasker
ptasker / gist:5526656
Created May 6, 2013 17:35
WordPress Maintenance Mode
<?php
//http://sivel.net/2009/10/wordpress-maintenance-mode-without-a-plugin-part-3/
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr($cookie, 'wordpress_logged_in_') )
$loggedin = true;
}
return $loggedin;
}