Skip to content

Instantly share code, notes, and snippets.

@m1r0
m1r0 / gist:8417210
Last active December 9, 2017 14:56
PHP-WP: Geocode address to lat and lng
function crb_get_lat_lng_by_address($address) {
$url = 'http://maps.googleapis.com/maps/api/geocode/xml?address=' . urlencode($address) . '&sensor=false';
$transient_key = substr(md5($address), 0, 20);
$coords_cache = get_transient( $transient_key );
if ( $coords_cache !== false ) {
return $coords_cache;
}
@macbleser
macbleser / wp-permissions-script
Created February 21, 2014 15:37
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
@nicholasohrn
nicholasohrn / automatically-title-post.php
Created March 4, 2014 18:17
Automatically title a post based on its type and category
<?php
/*
Plugin Name: Automatically Title Post
Description: Automatically title post based on post type and taxonomy.
Version: 1.0.0.RC.1
Author: Nick Ohrn of Plugin-Developer.com
Author URI: http://plugin-developer.com/
*/
function automatically_title_post($post_id, $post, $update) {
@soerenkampschroer
soerenkampschroer / Gruntfile.js
Created July 18, 2014 15:31
updated gruntfile for bootstrap
/*!
* Bootstrap's Gruntfile
* http://getbootstrap.com
* Copyright 2013-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
module.exports = function (grunt) {
'use strict';
@alexanderscott
alexanderscott / git-prune-file.sh
Created September 7, 2014 03:56
remove file from git history, prune & garbage collect, push removal to origin
#!/bin/bash
# Get filename from cmd-line arg
filename=$1
# Fetch all remote branches locally and setup tracking
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
git branch --track ${branch##*/} $branch
done
@diegocasmo
diegocasmo / ImageHelper.js
Last active August 29, 2015 14:10
Helper object to preload images.
define([
'jquery',
'underscore'
], function ($, _) {
var ImageHelper = {
initialize: function () {
var example = [
"img/image1.jpg",
"img/image2.jpg"
@pixeline
pixeline / ajax-handler-wp.php
Last active October 5, 2022 13:09
Custom ajax handler for Wordpress. Using admin-ajax.php, as is usually recommended, is very slow and does not allow the use of plugin shortcodes. Using a custom ajax handler like this bypasses that. http://wordpress.stackexchange.com/questions/170808/the-content-shows-shortcode-instead-of-parsing-it
<?php
/*
WORDPRESS SPECIFIC AJAX HANDLER (because admin-ajax.php does not render plugin shortcodes).
by [email protected]
credits: Raz Ohad https://coderwall.com/p/of7y2q/faster-ajax-for-wordpress
*/
//mimic the actual admin-ajax
define('DOING_AJAX', true);
if (!isset( $_REQUEST['action']))
@DanAncona
DanAncona / meteor-wrapasync.md
Last active September 11, 2017 14:43
Meteor vs. the Twitter API via wrapAsync and Twit

Twit and other Node libraries don't always quite drop into Meteor's reactive architecture right out of the box. Luckily Meteor makes adapting them super-duper easy with wrapAsync. It was so easy that I naturally tried all the more difficult ways first! Since I didn't find a nice gist or StackOverflow example, please enjoy this one.

In the template -

{{#with pos}}
  {{#if ready}}
    {{> singlePosition data }}
@peter76111
peter76111 / testcase.sh
Created January 18, 2016 01:26 — forked from jmbarbier/testcase.sh
Gandi systemd / docker failure at reboot testcase.
#!/bin/bash
# Test restart d'une VM sur instance de base Gandi Debian 8 + install par défaut de docker
VM=dockersystemd
gandi vm create --datacenter LU --memory 1024 --cores 2 --ip-version 4 --hostname $VM --image "Debian 8 64 bits (HVM)" --size 10G
echo "Installing docker"
gandi vm ssh $VM 'apt-get update && apt-get install -y curl'
gandi vm ssh $VM 'curl -sSL https://get.docker.com/ | sh'
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active May 14, 2025 21:35
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)