Skip to content

Instantly share code, notes, and snippets.

View Apeli's full-sized avatar

Aapo Virta Apeli

View GitHub Profile
@Apeli
Apeli / gist:6deed7b8019afee1f3c4
Last active August 29, 2015 14:09
Fix for Google Webfonts in html emails for Outlook
<!--
If you use Google Web fonts in html emails, all text tags that use the gwf font-name render with Times New Roman in Outlook (at least Outlook 2010), even if you have a fallback font specified.
You can't force the GWF to render, but you can fix the Times New Roman substituting.
Create the title twice, one without Google Webfonts for Outlook, one with the fonts for smarter browsers
Inside the Outlook-specific conditional block, open a hidden <div /> with style=display:none, then add a new conditional block after the correct title and close the hidden div.
-->
Kaikki Suomen kunnat sekä niiden maakunnat riveittäin. Sisältää joitakin jo kuntaliitosten myötä poistuneita kuntia (esim. Nilsiä, Kesälahti)
koodi kunta maakunta
001 Brändö Ahvenanmaa
002 Eckerö Ahvenanmaa
003 Finström Ahvenanmaa
004 Föglö Ahvenanmaa
005 Geta Ahvenanmaa
006 Hammarland Ahvenanmaa
007 Jomala Ahvenanmaa
{
"cities": [{
"city": "Askola",
"codes": [
"07230",
"07500",
"07510",
"07530",
"07580",
"07590",
@Apeli
Apeli / acf-field-names.gist.php
Last active November 14, 2017 21:05
Show Advanced Custom Fields field name on Wordpress admin on hover
//In functions.php
add_action('admin_head', 'show_acf_field_names');
function show_acf_field_names() {
echo '<style>
body:not(.post-type-acf-field-group) .acf-field:hover:before {
content: attr(data-name);
display: inline-block;
position: absolute;
@Apeli
Apeli / NCS to HEX color conversion
Last active June 25, 2018 11:08
Couldn't find a ncs to hex (or ncs to anything) color converter in PHP, so I translated the convert function from https://github.com/m90/ncs-color to PHP.
<?php
//Eats NCS S 3010-G20Y and puts out #a8bca0
function ncs2hex($ncs) {
$ncs = trim($ncs);
$ncs = strtoupper($ncs);
$ncs = preg_match("/^(?:NCS|NCS\sS)\s(\d{2})(\d{2})-(N|R|G|B|Y)(\d{2})?(R|G|B|Y)?$/", $ncs, $output_array);
$ncs = $output_array;
@Apeli
Apeli / Reset the pkeys of all tables in a postgres db
Created June 26, 2020 07:40
Reset the pkeys of all tables in a postgres db
DO
$$
DECLARE
tbl regclass;
nbrow bigint;
BEGIN
FOR tbl IN
SELECT c.oid
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace