Skip to content

Instantly share code, notes, and snippets.

View TomiToivio's full-sized avatar
👽
LaclauGPT!

Tomi Toivio TomiToivio

👽
LaclauGPT!
View GitHub Profile
@TomiToivio
TomiToivio / geocoder-plugin.php
Last active May 6, 2016 00:43
geocoder.php
<?php
/*
Plugin Name: Geocoder Plugin Example
Plugin URI: http://api.okf.fi/console/
Description: Example WordPress Plugin for Geocoder API
Version: 1.0
Author: Tomi Toivio
Author URI: http://fi.flossmanuals.net
License: GPL2
*/
@TomiToivio
TomiToivio / 0_reuse_code.js
Created June 29, 2014 07:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
local P = {}
AI_SOV = P
function P.ProposeDeclareWar( minister )
local ai = minister:GetOwnerAI()
local ministerCountry = minister:GetCountry()
local strategy = ministerCountry:GetStrategy()
local year = ai:GetCurrentDate():GetYear()
local month = ai:GetCurrentDate():GetMonthOfYear()
@TomiToivio
TomiToivio / scraperwiki.php
Last active August 29, 2015 13:58
Scraperwiki
#!/usr/bin/env php
<?
require 'scraperwiki.php';
$html = scraperwiki::scrape("https://www.eura2007.fi/rrtiepa/projektilista.php?rahasto=ALL&type=xml");
$eura = preg_replace("/&/", "&amp;", $html);
$projektilista = simplexml_load_string($eura);
$unique_keys = array('projektikoodi');
@TomiToivio
TomiToivio / scraper.php
Last active August 29, 2015 13:58
Scraper
<?php
$handle = fopen("eura.csv", "w");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.eura2007.fi/rrtiepa/projektilista.php?rahasto=EAKR&type=xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$eura = curl_exec($ch);
curl_close($ch);
$eura = preg_replace("/&/", "&amp;", $eura);
$projektilista = simplexml_load_string($eura);
foreach ($projektilista->projekti as $projekti):
@TomiToivio
TomiToivio / django.po
Created January 21, 2014 15:16
Booktype suomeksi
# This file is distributed under the same license as the Booktype package.
#
# Translators:
# Tomi Toivio <tomi@flossmanuals.net>, 2013
msgid ""
msgstr ""
"Project-Id-Version: Booktype\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-05-05 19:22+0200\n"
"PO-Revision-Date: 2013-12-20 04:06+0200\n"
@TomiToivio
TomiToivio / snippet
Last active December 28, 2015 20:39
Do something when admin posts a comment reply in WordPress.
/* Call the function when comment is posted */
add_action('comment_post', 'my_admin_reply');
function my_admin_reply($id) {
/* Only do it when posting from admin */
if (is_admin()) {
$mycomment = get_comment($id);
$mycommentid = $mycomment->comment_ID;
$mycommentparent = $mycomment->comment_parent;
(function(){var x,o,r,y,K,L,M,N,O,P,Q,R,z,q,A,S,T,U,u,V,W,X;u=function(b){return b.replace(/[a-zA-Z]/g,function(a){return String.fromCharCode(("Z">=a?90:122)>=(a=a.charCodeAt(0)+13)?a:a-26)})};Q=function(b){var a,d;d=[];for(a in b)d.push(a);return 0===d.length};z=function(b,a){return b.push.apply(b,a)};W=function(b,a){var d,c,e,f,g;f=b.split("");g=[];c=0;for(e=f.length;c<e;c++)d=f[c],g.push(a[d]||d);return g.join("")};S=function(b){var a,d,c,e;d=[];c=0;for(e=B.length;c<e;c++)a=B[c],z(d,a(b));return d.sort(function(a,
b){return a.i-b.i||a.j-b.j})};O=function(b,a){var d,c,e,f,g,h,i,j,k;h=[];e=b.length;f=b.toLowerCase();f=u(f);for(d=j=0;0<=e?j<e:j>e;d=0<=e?++j:--j)for(c=k=d;d<=e?k<e:k>e;c=d<=e?++k:--k)if(f.slice(d,+c+1||9E9)in a)i=f.slice(d,+c+1||9E9),g=a[i],h.push({pattern:"dictionary",i:d,j:c,token:b.slice(d,+c+1||9E9),matched_word:u(i),rank:g});return h};r=function(b){var a,d,c,e,f;d={};a=1;e=0;for(f=b.length;e<f;e++)c=b[e],d[c]=a,a+=1;return d};o=function(b,a){return function(d){var c,e,f;c=O(d,a);e=0;for(f=
@TomiToivio
TomiToivio / fm_read_new.tmpl
Last active December 21, 2015 10:49
Just saving the tweaks.
<!-- blah -->
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$filename = date("c") . ".kml";
file_put_contents($filename, $data);
?>