Skip to content

Instantly share code, notes, and snippets.

View lembitk's full-sized avatar

Lembit Kivisik lembitk

View GitHub Profile
@crofty
crofty / index.html
Last active October 22, 2021 08:24
A example of using Google Map tiles with the Leaflet mapping library - http://matchingnotes.com/using-google-map-tiles-with-leaflet
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
</head>
<body>
@msqr
msqr / LICENSE
Last active January 23, 2023 05:38
d3 gauge
This code is released under the MIT license.
Copyright (C) 2012 Matt Magoffin
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
@getdave
getdave / gist:4578295
Last active January 30, 2024 06:34
Gravity Forms - custom field validation function for checkboxes. Ensures all checkboxes have been checked.
// Replace 7 with the ID of your form and 13 with the ID of the field you want to force "all required"
// http://www.gravityhelp.com/documentation/page/Gform_field_validation
add_filter("gform_field_validation_7_13", 'validate_tcs', 10, 4);
function validate_tcs($result, $value, $form, $field) {
// Convert the checkbox input name value (returned as part of "field")
// into the "underscored" ID version which is found in the $_POST
foreach ($field['inputs'] as $input) {
$input_post_value = 'input_' . str_replace('.', '_', $input['id']);
@pmeenan
pmeenan / user-timing-rum.js
Last active January 18, 2024 23:46
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@lavoiesl
lavoiesl / subdirectory_loader.php
Last active June 15, 2022 17:03
MU plugins subdirectory loader. Enables the loading of plugins sitting in mu-plugins (as folders)
<?php
/**
* Plugin Name: MU plugins subdirectory loader
* Plugin URI: https://gist.github.com/lavoiesl/6302907
* Description: Enables the loading of plugins sitting in mu-plugins (as folders)
* Version: 0.1
* Author: github@lavoie.sl
* Author URI: http://blog.lavoie.sl/
*
@adactio
adactio / webmention.php
Last active March 16, 2024 22:15
Minimum viable webmention in PHP.
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
if (!isset($_POST['source']) || !isset($_POST['target'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
exit;
}
add_action('gform_after_submission', 'gform_synchronise_media_library', 10, 2);
function gform_synchronise_media_library($entry, $form) {
if(!function_exists('wp_generate_attachment_metadata')){require_once(ABSPATH . 'wp-admin/includes/image.php');}
$post_id = $entry['post_id'];
$fileupload_fields = GFCommon::get_fields_by_type($form, array("fileupload"));
foreach($fileupload_fields as $field){
$field_id = $field["id"];
$file_url = $entry["$field_id"];
if (isset($_FILES['input_' .$field_id]) && $file_url != '' && $file_url !=null){
@markgoodyear
markgoodyear / 01-gulpfile.js
Last active May 5, 2023 03:21
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
<?php
function twitter_metadata($metadata) {
$metadata['twitter:card'] = 'summary';
$metadata['twitter:creator'] = '@willnorris';
foreach (array('url', 'title', 'description', 'image') as $attr) {
if (array_key_exists("og:$attr", $metadata)) {
$metadata["twitter:$attr"] = $metadata["og:$attr"];
}
@jonathanbardo
jonathanbardo / install_elasticsearch.sh
Last active January 15, 2016 03:41
Install Elasticsearch
# Install on ubuntu trusty tahr 14.04
# I do this with root user, but if you sudo access with your user it will work too!
sudo su
# Update apt-get
apt-get update
# Install java jdk 7 or java jdk 8 or oracle jdk
apt-get install openjdk-7-jre-headless
# Make sure java is installed
java -version
# This should output: java version "1.7.XX"