Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
ailabs-software / URI.ts
Created June 2, 2017 02:17
Port of Closure's URI class to TypeScript
import goog = require("/AILabsToolkit/TClosure/goog");
import array = require("/AILabsToolkit/TClosure/array");
import asserts = require("/AILabsToolkit/TClosure/asserts");
import strings = require("/AILabsToolkit/TClosure/string/strings");
import structs = require("/AILabsToolkit/TClosure/structs");
import Map = require("/AILabsToolkit/TClosure/structs/Map");
import utils = require("/AILabsToolkit/TClosure/uri/utils");
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
public enum CardinalDirectionType
{
North ("n-resize"),
NorthEast ("ne-resize"),
East ("e-resize"),
SouthEast ("se-resize"),
South ("s-resize"),
SouthWest ("sw-resize"),
West ("w-resize"),
NorthWest ("nw-resize");
public enum CardinalDirectionType
{
North ("n-resize", new Coordinate(100, 0) ),
NorthEast ("ne-resize", new Coordinate(100, 0) ),
East ("e-resize", new Coordinate(100, 50) ),
SouthEast ("se-resize", new Coordinate(100, 100) ),
South ("s-resize", new Coordinate(50, 100) ),
SouthWest ("sw-resize", new Coordinate(0, 100) ),
West ("w-resize", new Coordinate(0, 50) ),
NorthWest ("nw-resize", new Coordinate(0, 0) );
var DEFAULT_ACTIVE_FIELDS;
var Lpipelinesystem_dataservice_PipelineDAL_2_classLit = createForClass('pipelinesystem.dataservice', 'PipelineDAL', 169);
function $compare_1(this$static, s1, s2){
var s1_rank, s2_rank;
s1_rank = $rankItem(this$static, s1);
s2_rank = $rankItem(this$static, s2);
if (s1_rank > s2_rank) {
return 1;
}
else if (s1_rank < s2_rank) {
@ailabs-software
ailabs-software / gist:5bd04b0a25565351221dd98a2c7d568b
Created June 21, 2017 14:52
TypeScript changing of type by localscope
var obj: Object = new Object();
class Puppet
{
public doTheatricalPuppet(): void
{
}
}
CKEDITOR.on('dialogDefinition', function(ev) {
if (ev.data.name == "link") {
var info = dialog.getContents("info");
info.elements.push({
type: "vbox",
id: "urlOptions",
children: [{
type: "hbox",
children: [{
id: "button",
@ailabs-software
ailabs-software / gist:697f36b47c1fff692c30e2c17eaa78f3
Created August 9, 2017 18:55
1500ms query on 7 million row table
EXPLAIN ANALYZE SELECT page_url, page_title, COUNT(*)::int FROM siteanalytics_pageview
WHERE domain=143 AND ( pageview_timestamp::date >= '7/10/2017'::date AND pageview_timestamp::date <= '8/9/2017'::date )
GROUP BY page_url, page_title ORDER BY count DESC LIMIT 10;
shorty=# \d siteanalytics_pageview
Table "public.siteanalytics_pageview"
Column | Type | Modifiers
-------------------------+--------------------------+-----------------------------------------------
domain | integer |
visit_id | uuid |
pageview_id | uuid |
page_url | text |
@ailabs-software
ailabs-software / gist:0fc4e939e0c9d31d46786053ebf061cb
Created June 5, 2018 01:33
Casting iterable to iterable of map of maps.
// Fails to work. Cast exception occurs as soon a value is accessed by key from one of the outer maps:
// e.g., iterable[0][outerKey] results in CastError
Map<Object, Map<Object, num> > reduceOpaqueIterable(Iterable<Object> windowValues)
{
return windowValues.map(
(inner) => (inner as Map).cast<Object, Map<Object, num> >() );
}
// Solved by re-creating the outer maps so the inner maps could be cast.
final results = new List< Map<Object, Map<Object, num> > >();
for (final value in windowValues)
{
Map<Object, Map<Object, num> > outerMap =
new Map<Object, Map<Object, num> >.fromEntries(
(value as Map).entries.map( (entry) => new MapEntry<Object, Map<Object, num> >(entry.key, (entry.value as Map).cast<Object, num>() ) )
);