Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
@niraj-shah
niraj-shah / tweet_button_callback.js
Last active December 12, 2015 06:29
Twitter API: Tweet Button Callbacks
function reward_user( event ) {
if ( event ) {
// do something
alert( 'Tweeted' );
}
}
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
@niraj-shah
niraj-shah / tweet_button.html
Last active December 12, 2015 06:29
Tweet Button HTML
<a href="https://twitter.com/intent/tweet?url=https://www.webniraj.com/2012/09/11/twitter-api-tweet-button-callbacks/&text=Twitter+API:+Tweet+Button+Callbacks"><i class="icon-twitter-sign icon-white"></i> Tweet</a>
@niraj-shah
niraj-shah / facebook_image_crop.php
Created February 7, 2013 10:10
Facebook API: Generating a Large Square Profile Image
<?php
function generate_ticket( $src, $l, $t, $r, $b ) {
// check to see if Image Functions Exist
if ( !function_exists ( "imagecreate" ) || !function_exists ( "imagecreatetruecolor" ) ) {
die( "No image create functions!" );
}
// get size of file
@niraj-shah
niraj-shah / bbc_social.html
Created February 7, 2013 10:12
Social BBC News Example
<html>
<head>
<title>BBC News - Like Button - Comments</title>
</head>
<body>
<!--
Code by: Niraj Shah - www.webniraj.com
-->
<!-- BBC Player -->
@niraj-shah
niraj-shah / image_gallery_1.html
Created February 7, 2013 10:13
jQuery Image Gallery (Example 1)
@niraj-shah
niraj-shah / image_gallery_2.html
Created February 7, 2013 10:14
jQuery Image Gallery (Example 2)
@niraj-shah
niraj-shah / base_facebook_old.php
Created February 13, 2013 11:31
Facebook Base SDK for PHP 5.3.x
<?php
protected function getCode() {
if (isset($_REQUEST['code'])) {
if ($this->state !== null &&
isset($_REQUEST['state']) &&
$this->state === $_REQUEST['state']) {
// CSRF state has done its job, so clear it
$this->state = null;
@niraj-shah
niraj-shah / base_facebook_new.php
Created February 13, 2013 11:31
Updated Facebook Base SDK for PHP 5.4.x
<?php
protected function getCode() {
$server_info = array_merge($_GET, $_POST, $_COOKIE);
if (isset($server_info['code'])) {
if ($this->state !== null &&
isset($server_info['state']) &&
$this->state === $server_info['state']) {
@niraj-shah
niraj-shah / tagged_photos.sql
Created February 20, 2013 15:03
Photos with the specified User tagged in FQL
SELECT pid, src, images FROM photo WHERE object_id IN ( SELECT object_id FROM photo_tag WHERE subject = 60506094 )
@niraj-shah
niraj-shah / s3cmd_install.sh
Created March 24, 2013 12:55
Installing s3cmd on Linux
# Using apt-get
sudo apt-get install s3cmd
# Using yum
sudo yum install s3cmd