SELECT
uid,
kv['c1'] AS c1,
kv['c2'] AS c2,
kv['c3'] AS c3
FROM (
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sequtils | |
| import nimpy | |
| import tables | |
| import intsets | |
| proc remove_duplications_nim(n: seq[int]): seq[int] {.exportpy.} = | |
| var t1 = initTable[int, int]() | |
| for t in n: | |
| discard t1.hasKeyOrPut(t, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import dedupnim # (dedupnim) https://gist.github.com/Bennyelg/d472cc66d3150d0bb549c14c9a17c253 | |
| def remove_duplicates(n): | |
| return list({e for e in n}) | |
| def remove_duplicates2(n): | |
| return {e: 1 for e in n}.keys() | |
| if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_lucky_version(real_floor: int): | |
| floors: List[int] = [] | |
| n = 1 | |
| def its_a_bad_luck_floor(floor_no: int): | |
| return "4" in str(floor_no) or "13" in str(floor_no) | |
| for i in range(1, real_floor + 1): | |
| if its_a_bad_luck_floor(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- query with stored plan | |
| CREATE or replace FUNCTION pybench1(id int) RETURNS text AS ' | |
| if (SD.has_key("plan")): | |
| plan = SD["plan"] | |
| else: | |
| plan = plpy.prepare("SELECT * FROM pagetimer pt, pagebrowser pb WHERE pt.idtimer = $1 and pt.idtimer = pb.idtimer", ["int4"]) | |
| SD["plan"] = plan | |
| rec = plpy.execute(plan, [id]) | |
| if (rec.nrows() > 0): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| proc merge[T](a: var seq[T], b: var seq[T]): seq[T] = | |
| result = newSeqOfCap[T](a.len + b.len) | |
| while a.len != 0 and b.len != 0: | |
| if a[0] < b[0]: | |
| result.add(a[0]) | |
| a = a[1..^1] | |
| else: | |
| result.add(b[0]) | |
| b = b[1..^1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import singleton | |
| import times | |
| import strformat | |
| for _ in countup(1, 3): | |
| var start = now() | |
| echo("Starting test..") | |
| echo(singletonInstance.value) | |
| echo(fmt"took: {(now() - start).milliseconds}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import times | |
| import sequtils | |
| import strutils | |
| import strformat | |
| type | |
| Singleton = object | |
| value*: int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| User = ref object | |
| name: string | |
| paymentStrategy: proc () | |
| proc strategyA() = | |
| echo("strategyA") | |
| proc strategyB() = | |
| echo("strategyB") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from decimal import Decimal | |
| def apply_high_order(ind, element, expression_elements): | |
| if element in ("*", "/"): | |
| if element == "*": | |
| evaluated_num = str(float(expression_elements[ind - 1]) * float(expression_elements[ind + 1])) | |
| else: | |
| evaluated_num = str(float(expression_elements[ind - 1]) / float(expression_elements[ind + 1])) | |
| expression_elements = expression_elements[:ind - 1] + [evaluated_num] + expression_elements[ind + 2:] | |
| elif element == "(": | |
| if expression_elements[ind + 2] == "+": |
NewerOlder