Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE aggregations (name regclass primary key, last_update timestamp);
INSERT INTO aggregations VALUES ('hourly_ssp_aggregates', now() - interval '15 minute');
CREATE OR REPLACE FUNCTION compute_hourly_ssp_aggregates()
RETURNS void LANGUAGE plpgsql AS $function$
DECLARE
start_time timestamp;
end_time timestamp := now() - interval '15 minute'; -- exclude in-flight requests
BEGIN
function(str){var ls=str.split(' - ')[1].split(', ').map(function(x){return x.split('[').join('').split(']').join('').trim()}).reduce(function(acc,cur,i){if(cur.split(': ').length>1){key=cur.split(': ')[0].trim();key=key.split(' ').join('_').toLowerCase();if(key=='advertiser_domains'){val=cur.split(': ')[1].trim().split(',')}else{val=cur.split(': ')[1].trim()}acc[key]=val}else{key=cur;val='random';acc[key]=val}return acc},{});timestamp=str.trim().slice(0,19);timestamp=timestamp.slice(0,10)+'T'+timestamp.slice(11,19);key='timestamp';ls[key]=timestamp;ls.floor_price=parseFloat(ls.floor_price)||0.0;ls.cpm=Number(ls.cpm)||0.0; ls.gross_price = Number(ls.gross_price) || 0.0; ls.net_price = Number(ls.net_price) || 0.0; ls.ssp_auction_price = Number(ls.ssp_auction_price) || 0.0; ls.dsp_bid_price=Number(ls.dsp_bid_price) || 0.0; ls.date_utc=timestamp.slice(0,10);ls.year=timestamp.slice(0,4);ls.month=timestamp.slice(5,7); ls.day=timestamp.slice(8,10);ls.hour=timestamp.slice(11,13); return ls}
2017-05-15 17:02:10 - Adv Pixel Id: 124, Campaign Type: PD, Event Type: IMPRESSION, Profile Id: 124, Site Id: 13691, Ad Slot: div-gpt-ad-1474908624076-4, Ad Size: 300x600, Impression Type: IMAGE, CPM: 1.68, DSP Campaign Id: 367284, Random Id: 2135103719, Advertiser Domains: [vueling.com], Uniq SSP Req Id: 7330483698636661129, Uniq SSP Impr Id: 6430569388443789764, Uniq SSP Resp Id: 3, Open X Campaign Id: null, Open X Creative Id: null, Open X Creative Size Id: null, Deal Id: NA, Tag Id: NA, Pub Group Id: NA, Adapter Type: HTTP, Net Price: 1.68, Gross Price: 1.68, SSP Auction Price: 1.68, Publisher Id: NA, Server Region: null, Dsp Bid Price: 1.68, User IP: 82.230.86.67, SeenBefore: true, URL: http%3A%2F%2Fwww.hebdocine.com%2F20-films-injustement-detestes%2F8%2F, Domain: hebdocine.com, UUID: 3D8DFF425A544FDD8B756722DF1C64DA, Redirect URL: null
2017-05-16 17:03:54 - Adv Pixel Id: 125, Campaign Type: PD, Event Type: IMPRESSION, Profile Id: 125, Site Id: 32, Ad Slot: AUM, Ad Size: 300x250, Impression Type: IMAGE, CPM: 1.4178984, DSP Campaign Id: null, Random Id: 1707886840, Advertiser Domains: [thepoplr.com], Uniq SSP Req Id: 8566447237721474344, Uniq SSP Impr Id: 7303722574278514726, Uniq SSP Resp Id: 0, Open X Campaign Id: null, Open X Creative Id: null, Open X Creative Size Id: null, Deal Id: NA, Tag Id: aW1vcmUuY29tX3B1cmNoX1lfUl8wXzNfMzAweDI1MA, Pub Group Id: 17, Adapter Type: OPENRTB, Net Price: 1.4178984, Gross Price: 1.4178984, SSP Auction Price: 1.42,Auction Type: null,Server Region: west,Generated Timestamp: null, Publisher Id: imore.com, Dsp Bid Price: 1.4178984, User IP: 143.55.122.47,IP Addrs: 143.55.122.47, SeenBefore: true, URL: http%3A%2F%2Fwww.imore.com%2Fhow-find-and-remove-files-other-category-os-x, Domain: imore.com, UUID: F01F718727AC4228A506A0AFDE6DD311, Redirect URL: null
1. Detect the person entering the room and automatically open the door, lock the door when a person leaves
2. Automatically wake up "a computer" and open some programs on it (configurable)
3. Play music according to time of day and recent music preferences (difficult)
4. Automatically toggle lights and curtains based on ambient light in the room.(using motors and such, but the hardware comes later, if we can just generate the right signals, that would be a huge step)
5. Have 2-3 "profiles" for the room which can be toggled by voice commands.
6. Integrate all this with mobile (Optional)
7. Identification and authentication of all people entering the room, if face not present in database, say unknown person.
8. RFID tag all "movable" items in room and detect when sth is taken out.
9. Add motion control