Skip to content

Instantly share code, notes, and snippets.

View tokumine's full-sized avatar

tokumine

  • London, UK
View GitHub Profile
@tokumine
tokumine / gist:615cf5e191fae470f1b7b15b6c3b6ff1
Created December 17, 2023 02:43
Google Gemini API RAG Grounding with citations example prompt
Given a user query and a list of sources, write a response that cites individual sources as comprehensively as possible. Each source is independent and might repeat or contradict content from other sources. The response should be directly supported by the given sources and cite them appropriately with a [i] notation following a statement that is supported by [i]. If a statement is based on multiple sources, all of these sources should be listed in the brackets, for example [i, j, k].
User: What planet is known to have "Goldilocks" conditions?
Sources:
[1] The Goldilocks planet: why Earth is our oasis - Curious: So here we are, on Earth—our Goldilocks planet. Its position and movement in space makes it not too hot, and not too cold. https://www.science.org.au/curious/space-time/goldilocks-planet
[2] Which inner planet has Goldilocks conditions?: What is the Goldilocks Zone and why does it matter in the search for ET?: More than just temperature
After all, Earth isn't the only planet in the Sun's Goldilock
@tokumine
tokumine / index.html
Created February 17, 2013 01:58
(enable geo access plz). Customizable mimic of howbigreally.com
<!DOCTYPE html>
<html>
<head>
<title>Grandiose</title>
<style>
body, html{
height:100%;
margin:0;
padding:0;
@tokumine
tokumine / migrate_github.md
Last active December 12, 2015 02:28
migrate a private github repository to your own hosted git.

How-to migrate your private github repositories to an external server

Because of the recent ruby/rails security scares I wanted to move our private github repository to a more secure location that is only accessible by our small team via ssh keys on an unknown port. It's worth remembering that private repos on github are not encrypted, and so are only as safe as the ruby/network layer that wraps it. To be fair, private repos were never advertised as secure storage, despite being used that way.

This is a huge 'if', but /if/ github is compromised not only will your sourcecode stand a high chance of being exposed (commercial damage, elevated risk of XSS & SQL injection), but your web applications may also be vulnerable to session spoofing in addition to possibly granting access via API keys and passwords to the usual range of external APIs, probably including commercial ones. We all code in a secure way, but who wants to have that tested in public?

It is trivially easy to mitigate this risk

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tokumine
tokumine / mp_scrape.rb
Created May 23, 2012 21:07
Scrape MP's details, address, and ages from BBC democracy live
require 'rubygems'
require 'json'
require 'net/http'
require 'open-uri'
require 'nokogiri'
require 'date'
require 'csv'
page_counter = 1
base_domain = "news.bbc.co.uk"
@tokumine
tokumine / hetzner
Created February 2, 2012 15:06
Hetzner EX 4S Unixbench, dd and htparm results
The Unixbench results for the Hetzner EX 4S servers recently featured on HackerNews. (dd and htparm tests at the bottom)
- http://news.ycombinator.com/item?id=3537513
- http://www.hetzner.de/en/hosting/produkte_rootserver/ex4s
To compare with AWS, see the Unixbench results from: http://blog.cloudharmony.com/2010/05/what-is-ecu-cpu-benchmarking-in-cloud.html
TLDR; the €59/mo EX 4S scores higher (1729) than AWS m2.4xlarge (1511) on single threaded loads.
Postscript
@tokumine
tokumine / labels.cartodb
Created January 27, 2012 17:57
carto to use labels in CartoDB maps
Just a quick sketch to explain how to use labels in CartoDB:
http://dl.dropbox.com/u/193220/CartoDB/labels.png
Something like this should work while we sort out exactly how to release this:
#populated_places_points_2{
marker-fill:#0099FF;
marker-line-color:white;
marker-line-width:1;
@tokumine
tokumine / postgis.py
Created January 21, 2012 00:28
Hacked imposm postgis.py to enable imports to work with PostGIS 2.0
# On OSX, this Imposm file is found at: /Library/Python/2.7/site-packages/imposm/db/postgis.py. YMMV
# Hack basically comments out all the elements relating to modifying the geometry_columns table.
# In PostGIS 2.0 this is a view and handled transparently.
# Copyright 2011 Omniscale (http://omniscale.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@tokumine
tokumine / gist:1648529
Created January 20, 2012 17:21
density.sql
UPDATE my_table SET my_var_per_km2 = (my_var / ST_Area(ST_transform(the_geom, 954009)) /10^6)
@tokumine
tokumine / ubuntu_laptop.md
Created January 9, 2012 23:33
Best Ubuntu laptop?

Weirdly, there's not an awful lot of information on what makes a light, fast and modern Linux laptop on the internet, even for a popular distribution like Ubuntu. I like to run Ubuntu as, for better or worse, it's what we use on our production systems.

Normally with linux laptops, you run the gauntlet of esoteric specialist hardware matched up with shaky drivers - a sure fire recipe for burning a weekend (or few weeks even). It's such drudgery to have to plod through all this stuff. I need a decent laptop that I can install Ubuntu on and for everything to just work.

By everything, I mean all of it - wireless (b/g/n), gigabit ethernet, battery indicator, cpu stepping, VGA port/dongle, bluetooth, HDMI port, sleep, SD card reader, camera, microphone, usb, multitouch (especially two-finger scroll) and special laptop keys like brightness and volume. I wanted as near to zero config as possible with good default choices.

I decided to take an educated guess on such a linux laptop recently: the Samsung 350U (speci