Skip to content

Instantly share code, notes, and snippets.

@karlkranich
karlkranich / apitest.php
Last active July 17, 2018 14:49
Updated PHP code to use the Google Sheets API. See usage instructions at http://karl.kranich.org/2015/04/16/google-sheets-api-php/ More examples at https://gist.github.com/karlkranich/afa39e3d778455b38c38
<?php
// apitest.php
// by Karl Kranich - karl.kranich.org
// version 3.1 - edited query section
require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
include_once "google-api-php-client/examples/templates/base.php";
$client = new Google_Client();
@DarrylD
DarrylD / directive.js
Created February 14, 2015 22:02
ionic slide box dynamic height - fixes the issue where the slide boxes aren't taking up the full height of the device
app.directive('dynamicHeight', function() {
return {
require: ['^ionSlideBox'],
link: function(scope, elem, attrs, slider) {
scope.$watch(function() {
return slider[0].__slider.selected();
}, function(val) {
//getting the heigh of the container that has the height of the viewport
var newHeight = window.getComputedStyle(elem.parent()[0], null).getPropertyValue("height");
if (newHeight) {
@rudyryk
rudyryk / redactor.imagelink.js
Last active March 26, 2018 11:16
Plugin for Imperavi Redactor v10.x.x -- Insert image by link (feature is missing by default)
<?php
function send_http_auth_headers(){
header('WWW-Authenticate: Basic realm="Your Website Name Restricted"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please speak to an administrator for access to the this feature.';
exit;
}
add_action('template_redirect', 'maybe_add_http_auth_basic', 0);
function maybe_add_http_auth_basic(){
# Add your specific URI segment (i.e. http://example.com/segment-string/)
@frankiejarrett
frankiejarrett / gist:8cd04bd33e49bbd6e3b7
Last active September 19, 2015 09:04
Force WP JSON REST API endpoints to always be served over HTTPS
<?php
/**
* Force WP JSON REST API endpoints to always be served over HTTPS
*
* @action wp_json_server_before_serve
*
* @return void
*/
function fjarrett_wp_json_force_ssl() {
@Kevinlearynet
Kevinlearynet / gist:10287914
Created April 9, 2014 16:15
MySQL query to delete 'wp_posts' rows and 'wp_postmeta' rows from a WordPress database
# Delete all posts with given post type
DELETE FROM wp_posts WHERE post_type = 'shop_order';
# Delete all orphaned post_meta
DELETE wp_postmeta FROM wp_postmeta
WHERE NOT EXISTS (
SELECT * FROM wp_posts
WHERE wp_postmeta.post_id = wp_posts.ID
);
@iandunn
iandunn / programmatic_login.php
Last active March 7, 2023 18:18
Programmatically log in a WordPress user
/**
* Programmatically logs a user in
*
* @param string $username
* @return bool True if the login was successful; false if it wasn't
*/
function programmatic_login( $username ) {
if ( is_user_logged_in() ) {
wp_logout();
@jdcantrell
jdcantrell / xipio.conf
Last active November 29, 2016 16:48
nginx config for having xip.io working with local dev
upstream xip_app_server {
server localhost:8080 fail_timeout=0;
}
server {
listen 80;
server_name "~^(?<base_dir>.+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.xip.io$";
access_log /var/log/nginx/xip.access.log main;
error_log /var/log/nginx/xip.error.log;
@chekalsky
chekalsky / tweets.redactor.js
Last active January 9, 2019 23:36
Imperavi Redactor Plugin for Embedding Tweets Usage: mention "tweets" in "plugins" setting of you redactor.
/**
* Imperavi Redactor Plugin for Embedding Tweets
* for version >= 9.1
*
* @author Ilya Chekalskiy <[email protected]>
* @version 0.2.2
*/
if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {};
RedactorPlugins.tweets = {
@azat-co
azat-co / file-structure
Created June 6, 2013 23:24
Instagram Gallery: A demo app build with Storify API and Node.js http://storify.com/storifydev/instagram-gallery/
- index.js
- package.json
- public/js/main.js
- public/index.html
- css/bootstrap-responsive.min.css
- css/flatly-bootstrap.min.css