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 ( | |
"github.com/jackc/pgconn" | |
"github.com/pkg/errors" | |
) | |
func main() { | |
if err != nil { | |
var pgerr *pgconn.PgError | |
if errors.As(err, &pgerr) && pgerr.SQLState() == database.DUPLICATE { | |
t.Log(err) |
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
-- show *blocked* queries (not the same as idle) | |
SELECT | |
pid, | |
usename, | |
pg_stat_activity.query_start, | |
now() - pg_stat_activity.query_start AS query_time, | |
query, | |
state, | |
wait_event_type, | |
wait_event |
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
with "config/learnada_config.gpr"; | |
project Learnada is | |
-- This is the magic | |
package Linker is | |
for Switches ("Ada") use ("-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/"); | |
end Linker; | |
for Source_Dirs use ("src"); | |
for Object_Dir use "obj"; |
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
""" | |
Write functions that: | |
a. detects if an array/slice has duplicates | |
b. detects what the duplicates are | |
c. counts the duplicates | |
You may tackle these in any order | |
You may alter the signatures of the skeletons to meet your needs | |
""" | |
from typing import List, Mapping, TypeVar, Iterable | |
import pytest |
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 org.apache.spark.sql.functions._ | |
import org.apache.spark.sql.{Dataset, Encoder, Encoders} | |
import org.apache.spark.sql.expressions.Aggregator | |
import org.apache.spark.sql.TypedColumn | |
case class Food(key: String, date: String, numeric: long, text: String) | |
object AggregateLatestFoods { | |
/** Load the data elsewhere **/ | |
def aggregateLatestFoods(in: Dataset[Food]): Dataset[Food] = |
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
Mandelbrot set in p5.js (see sketch.js) with grayscale shading |
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
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.sound.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/4.0.0/math.min.js" integrity="sha256-SXLRPQMQE3pP06076EMmcA5x6Qv5Wu0rfyH51xcMd8c=" crossorigin="anonymous"></script> | |
<link rel="stylesheet" type="text/css" href="main.css"> | |
</head> | |
<body> | |
<script src="sketch.js"></script> |
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 shapeless._ | |
import ops.record._ | |
import ops.hlist._ | |
trait TimeColumns { | |
val date: Date | |
val segment_time: Timestamp | |
val station_id: Integer | |
val start_time: Timestamp | |
val end_time: Timestamp |
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
trait TimeColumns { | |
val date: Date | |
val segment_time: Timestamp | |
val station_id: Integer | |
val start_time: Timestamp | |
val end_time: Timestamp | |
} | |
case class Viewership( | |
date: Date, segment_time: Timestamp, station_id: Integer, start_time: Timestamp, end_time: Timestamp, |
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 matchViewershipWithSchedules[T, RESULT]( | |
viewership: Dataset[T], schedules: Dataset[Schedule])( | |
// You need this so that RESULT can be used as a type parameter | |
// inside the body of the function. A quirk of how Scala conforms | |
// to Java's type erasure rules | |
implicit ev: TypeTag[RESULT]): Dataset[RESULT] = { | |
import session.implicits._ | |
viewershipWithQHAndDate.toDF.as('viewership).join(schedules.toDF.as('schedules), | |
$"viewership.date" === $"schedules.date" |
NewerOlder