Skip to content

Instantly share code, notes, and snippets.

View KWKdesign's full-sized avatar

Kevin Klingelhoefer KWKdesign

View GitHub Profile
@KWKdesign
KWKdesign / keybase.md
Created February 9, 2016 16:23
Keybase ID

Keybase proof

I hereby claim:

  • I am kwkdesign on github.
  • I am kwksilver (https://keybase.io/kwksilver) on keybase.
  • I have a public key whose fingerprint is 9133 8EFE C32E 1CD8 53D4 6AD6 5586 F203 596B DD97

To claim this, I am signing this object:

@KWKdesign
KWKdesign / cheat_sheet.sql
Created July 7, 2015 02:57
Schemaverse Cheat Sheet
-- Schemaversus Cheat Sheet
-- Schemaversus.com
-- Scheaverse.com
-- https://github.com/Abstrct/schemaversus
-- View your player stats
SELECT * FROM my_player;
-- Create some ships on your home planet to mine some resources
@KWKdesign
KWKdesign / schemaverse_planet_rename_demo.sql
Created February 2, 2015 01:59
Schemaverse Planet Rename Demonstration
select row_number, ( case row_number % 12
when 0 then 'Aethra'
when 1 then 'Mony'
when 2 then 'Semper'
when 3 then 'Voit'
when 4 then 'Lester'
when 5 then 'Rio'
when 6 then 'Zergon'
when 7 then 'Cannibalon'
when 8 then 'Omicron Persei'
@KWKdesign
KWKdesign / schemaverse_galaxy_map_creation.sql
Last active August 29, 2015 14:14
Schemaverse Galaxy Map Generation
-- example image: http://imgur.com/9eGABd6
/*
-- map generation variable declarations
r numeric;
a numeric;
b numeric;
turns int := 1; -- values >= 1
arms int := 4;
loc point;
*/
@KWKdesign
KWKdesign / schemaverse_example.sql
Last active August 29, 2015 14:13
Schemaverse Example Fleet Script
insert into my_fleets ( name ) values ( 'main' );
update my_fleets set
script_declarations = '
my_player_id int := get_player_id( session_user );
cash bigint;
ship record;
planet record;
target record;
',
@KWKdesign
KWKdesign / rot13.sql
Created January 10, 2015 23:06
Postgres ROT13
create or replace function pg_temp.rot13( string text )
returns text as $rot13$
begin
return translate( string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm' );
end $rot13$ language plpgsql;
@KWKdesign
KWKdesign / packed_circle_map.sql
Last active August 29, 2015 14:12
Schemaverse Packed Circle Map Creation
select
100000::numeric radius,
0::numeric y,
0::numeric a,
0::numeric b,
( null )::point ta,
( null )::point tb,
0::numeric angle,
1::int i,
0::int cnt,
@KWKdesign
KWKdesign / circle_map.sql
Last active August 29, 2015 14:12
SV Circle Map Creation
-- while ( select count(1) from planet ) < ( select count(1) from player ) * 1.05 loop
while ( select count(1) from planet ) < 2000 loop
for new_planet in
select nextval( 'planet_id_seq' ) as id,
case ( random() * 11 )::integer % 12
when 0 then 'Aethra_' || generate_series
when 1 then 'Mony_' || generate_series
when 2 then 'Semper_' || generate_series
when 3 then 'Voit_' || generate_series
when 4 then 'Lester_' || generate_series
@KWKdesign
KWKdesign / ships_heatmap.sql
Last active August 29, 2015 14:05
Schemaverse: Ships Heatmap SQL
with max_xy as (
select greatest(
max( abs( location_x ) ),
max( abs( location_y ) )
) v
from planets
),
scale as (
select m * ceil( v / m ) scale from (
select 10 ^ floor( log( v ) ) m, v
@KWKdesign
KWKdesign / attack_heatmap.sql
Last active August 29, 2015 14:05
Schemaverse: Attack Heatmap SQL
with max_xy as (
select greatest(
max( abs( location_x ) ),
max( abs( location_y ) )
) v
from planets
),
scale as (
select m * ceil( v / m ) scale from (
select 10 ^ floor( log( v ) ) m, v