Skip to content

Instantly share code, notes, and snippets.

@cdnsteve
cdnsteve / facebook_user_likes_page_check.js
Created December 6, 2012 16:57
JavaScript: Facebook check if user likes page
/* Source: http://stackoverflow.com/questions/5093398/how-to-check-if-a-user-likes-my-facebook-page-or-url-using-facebooks-api
*/
function parsePageSignedRequest() {
if (isset($_REQUEST['signed_request'])) {
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
@cdnsteve
cdnsteve / facebook_user_likes_page_check.php
Created December 6, 2012 16:59
PHP: Facebook check if user likes page
<?php
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$app_data = isset($data["app_data"]) ? $data["app_data"] : '';
$_REQUEST["fb_page_id"] = $data["page"]["id"];
$access_admin = $data["page"]["admin"] == 1;
<?php
// http://www.elasticsearch.com/docs/elasticsearch/rest_api/
class ElasticSearch {
public $index;
function __construct($server = 'http://localhost:9200'){
$this->server = $server;
}
(function() {
var iframes = document.getElementsByTagName('iframe');
for (var i = 0; i < iframes.length; i++) {
var iframe = iframes[i];
var players = /www.youtube.com|player.vimeo.com/;
if(iframe.src.search(players) !== -1) {
var videoRatio = (iframe.height / iframe.width) * 100;
iframe.style.position = 'absolute';
@cdnsteve
cdnsteve / gist:5396612
Last active April 4, 2020 11:46 — forked from jaredhanson/gist:2559730
Node.js: Restify and Passport for FB
// Based off example code from Hal Robertson
// https://github.com/halrobertson/test-restify-passport-facebook
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao
var restify = require('restify')
// config vars
var FB_LOGIN_PATH = '/api/facebook_login'
var FB_CALLBACK_PATH = '/api/facebook_callback'
var FB_APPID = '<<YOUR APPID HERE>>'
@cdnsteve
cdnsteve / drupal-password-reset.php
Last active December 18, 2015 04:18
Place this in your /root drupal directory. Change NEWPASSHERE to the new password for the root user. run yoursite.com/drupal-password-reset.php Take the output new password hash then go into MySQL and enter it, replacing: PASSWORDHASHOUTPUT This updates the admin user account to the new password.
<?php
/*
* Resets password, copy this into Users table in MySQL
* Drupal 7
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
@cdnsteve
cdnsteve / Drupal 7 Fix for Appfog tmp
Created December 27, 2013 22:21
RE: Drupal Error on Appfog Warning: tempnam(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): Just add this snippet to settings.php without changing core. Flush your cache and then you're good to go!
/**
* Force location of /tmp for Appfog
*/
$conf['file_temporary_path'] = realpath($_SERVER['DOCUMENT_ROOT'].'/../tmp');
/* END */
@cdnsteve
cdnsteve / vagrant_commands
Last active January 2, 2016 12:59
Vagrant Commands
# Checkout https://drupal.org/node/2146223
# And https://github.com/mikebell/drupaldev-nginx
#
##
# cd ~/Vagrant
# vagrant box list
# vagrant init ubuntu12
@cdnsteve
cdnsteve / number_formatter.php
Created January 15, 2014 14:47
PHP Number converter - converts any number format (English, French, Strings, ints) and returns double (float)
<?php
function validateCleanPrice($num) {
$cleanString = preg_replace('/([^0-9\.,])/i', '', $num);
$onlyNumbersString = preg_replace('/([^0-9])/i', '', $num);
$separatorsCountToBeErased = strlen($cleanString) - strlen($onlyNumbersString) - 1;
@cdnsteve
cdnsteve / jquery_rollovers.js
Created January 29, 2014 03:27
jQuery Rollovers
/**
* Image RollOver Effect
* ========================================================================
*/
jQuery(".rollover").hover(
function () {
var iconName = jQuery(this).attr("src");
var rollover = iconName.replace( /active/, 'rollover' );
jQuery(this).attr({ src: rollover });
},