Skip to content

Instantly share code, notes, and snippets.

View mgrubinger's full-sized avatar

Martin Grubinger mgrubinger

View GitHub Profile
@mgrubinger
mgrubinger / exportCSV
Created April 2, 2015 09:54
export pdf from php
function export_csv() {
$filename = "file_" . date('Y-m-d');
// get csv data
$data = $this->get_csv_data(); // expects: array with lines as array
// define header
$header = array('col1', 'col2', 'col3');
@mgrubinger
mgrubinger / PHPMapTileDownloader.php
Last active July 30, 2021 22:30
PHPMapTileDownloader: Simple PHP script to download map tiles from a tileserver (e.g. to create offline leaflet maps). Disclaimer: make sure the tile provider allows bulk downloading!
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>PHPMapTileDownloader</title>
<style>
body {
font-family: 'Helvetica', sans-serif;
text-align: center;
margin-top: 20px;
@mgrubinger
mgrubinger / wai-aria.use.css
Last active August 24, 2016 10:06 — forked from nfreear/wai-aria.use.css
CSS bookmarklet to highlight WAI-ARIA landmark roles etc. | Inspired by the Juicy Studio Accessibility toolbar - works in Chrome..
/*!
CSS helper to highlight WAI-ARIA landmark roles etc.
NDF, 3 December 2013.
http://w3.org/TR/wai-aria/roles#landmark_roles
Inspiration: https://addons.mozilla.org/en-US/firefox/addon/juicy-studio-accessibility-too/
javascript:
(function(){
/* System Fonts as used by Medium and WordPress */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
@mgrubinger
mgrubinger / systemfontstack.css
Created October 25, 2018 08:12
System Font Stack CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
@mgrubinger
mgrubinger / jQueryFormDatatoArray.js
Last active November 22, 2018 13:44
jQuery Form Data to Array
var data = $(this).serializeArray().reduce(function(obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
@mgrubinger
mgrubinger / getCurrentGitBranch.php
Last active December 4, 2018 07:16
Get current Git Branch in PHP
/*
Get current Git Branch in PHP
See: https://stackoverflow.com/a/7448133/3091226#
*/
$stringfromfile = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
$firstLine = $stringfromfile[0]; //get the string from the array
$explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string
$explodedstring = array_slice($explodedstring , 2);
$branchname = trim(implode("/", $explodedstring));
a[href="/login"] {
display: none !important;
}
@mgrubinger
mgrubinger / selectbox-limit-max-selections.js
Created February 13, 2019 14:26
Limit the maximum of currently selected options for a selectbox
(function() {
var verified = [];
document.querySelector('#myselector').onchange = function(e) {
if (this.querySelectorAll('option:checked').length <= 3) {
verified = Array.apply(null, this.querySelectorAll('option:checked'));
} else {
Array.apply(null, this.querySelectorAll('option')).forEach(function(e) {
e.selected = verified.indexOf(e) > -1;
});
}
@mgrubinger
mgrubinger / Image.js
Last active September 18, 2020 07:47
Gatsby generic Image component. Use with <Image filename="myimg.jpg"/>. Original idea: https://noahgilmore.com/blog/easy-gatsby-image-components/
import Img from "gatsby-image";
import { StaticQuery, graphql } from "gatsby";
import React from "react";
export default props => (
<StaticQuery
query={graphql`
query {
images: allFile {
edges {