Skip to content

Instantly share code, notes, and snippets.

View file_get_contents_curl.php
<?php
// http://25labs.com/alternative-for-file_get_contents-using-curl/
function file_get_contents_curl($url, $retries=5)
{
$ua = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
if (extension_loaded('curl') === true)
{
View Swipe.js
(function(){ //Self executing, anonymous function
//Leave out above if including in already existing script
function Swipe(){
var firstX, lastX;
function swipeRight(){
View color-thief-example.js
// Include Color Thief Script
// https://github.com/lokesh/color-thief
function colorChange(){
//Be sure to include <img id="coverImage" src="" alt=""/>
var $myImage = $("#coverImage");
var colorThief = new ColorThief();
//Grabs 8 swatch color palette from image and sets quality to 5 (0 =slow, 10=default/fast)
var cp = colorThief.getPalette($myImage[0], 8, 5);
View RGB-Hex.js
///////////////////////////////////////////////////////////////////////////////////
/// Colection of RGB to HSB, HSB to RGB convert functions
/// Source: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
///////////////////////////////////////////////////////////////////////////////////
/**
* componentToHex convert two digit htx value to R, G or B chanel value
* @param number c value from 0 to 225
* @return string value of R, G or B chanel
* @usage //alert (componentToHex(255)); //ff
@waqasy
waqasy / upload2facebook
Created Oct 24, 2015 — forked from nseo/upload2facebook
A sample code to upload an image file to facebook using Facebook javascript sdk
View upload2facebook
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Hello FB</title>
</head>
<body>
<div id="fb-root"></div>
<div id="fb-content"></div>
<div>
@waqasy
waqasy / facebook.js
Created Oct 24, 2015 — forked from koolay/facebook.js
facebook share
View facebook.js
var Share = {};
Share.fb = function (link, title, sumary, image, winWidth, winHeight) {
var shareUrl = 'https://www.facebook.com/dialog/feed?';
shareUrl += 'app_id=141676832590601';
shareUrl += '&link=' + encodeURIComponent(link);
shareUrl += '&picture=' + encodeURIComponent(image);
shareUrl += '&name=' + title;
shareUrl += '&caption=' + "";
shareUrl += '&description=' + sumary;
@waqasy
waqasy / social.js
Created Oct 24, 2015
Facebook Login
View social.js
/**
* @author www.juliocanares.com/cv
* @email juliocanares@gmail.com
*/
var getJSUserData, loginUser, postToFacebook;
getJSUserData = function (callback) {
FB.getLoginStatus((function (response) {
if (response.status === "connected") {
@waqasy
waqasy / wp-db.tutorial.php
Created Jul 28, 2016 — forked from benbalter/wp-db.tutorial.php
WordPress DB Tutorial
View wp-db.tutorial.php
<?php
//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' );
//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
View array_value_exists.php
/* This function check a array value exists in an indexed array or numeric array */
function indexed_in_array($value, $array){
if (in_array($value, $array))
{
return true;
}
else
{
return false;
}
@waqasy
waqasy / simple-json-api.php
Created Aug 6, 2016 — forked from daggerhart/simple-json-api.php
Simple Read-Only JSON API example for WordPress
View simple-json-api.php
<?php
/**
* Class Simple_Json_Api
*/
class Simple_Json_Api {
/**
* The top level argument for the endpoint.
* ex http://example.com/myjson/post/1