Skip to content

Instantly share code, notes, and snippets.

View TomiToivio's full-sized avatar

Tomi Toivio TomiToivio

View GitHub Profile
@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 / 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');
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 / 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
@TomiToivio
TomiToivio / getbook.inc.php
Created April 4, 2012 00:13
fi.flossmanuals.net modified getbook
<?php
//we need this lib for deleting dirs
include_once("lib/files.inc.php");
function getbook_admin() {
if(!is_dir("tmp")) mkdir("tmp");
$update = tempnam("tmp/", "update_");
$updatetext.= _("Processing...")."<br>"._("Requesting book");
$book = $_POST['book'];
@TomiToivio
TomiToivio / django.po
Created April 14, 2012 16:07
Booktype Finnish Localization
# This file is distributed under the same license as the Booktype package.
#
# Tomi Toivio <tomi@flossmanuals.net>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: Booktype\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-04-08 23:25+0200\n"
"PO-Revision-Date: 2012-04-14 18:59+0300\n"
"Last-Translator: Tomi Toivio <tomi@flossmanuals.net>\n"
<div class="recent-activity">
<h2>Users online:</h2>
{% for key, value in users %}
{% for username in value %}
<div class="user"><a href="{% url view_profile username %}" class="user"><div class="image"><img src="{% url view_profilethumbnail username %}?width=24" al\
t="{{username}}"></div><b>{{ username }}</b></a></div>
{% endfor %}
{% endfor %}
</div>
import sputnik
client_id = sputnik.get("sputnik:client_id")
sputnikchannels = sputnik.smembers("sputnik:channels")
chnl = {}
for ch in sputnik.rkeys("sputnik:channel:*:channel"):
chnl[ch] = sputnik.smembers(ch)
# This file is part of Booktype.
# Copyright (c) 2012 Aleksandar Erkalovic <aleksandar.erkalovic@sourcefabric.org>
#
# Booktype is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Booktype is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
{% extends "base.html" %}
{% load i18n %}
{% block header %}
<title>Booktype</title>
<script>
$(function() {
$("#formsignin").booksparkSignin({'url': '{% url signin %}'});
$("#formregister").booksparkRegister({'url': '{% url signin %}', 'redirect': '{% url view_profile 'XXX' %}'});