Skip to content

Instantly share code, notes, and snippets.

@cyx
cyx / postgres_queries_and_commands.sql
Created October 25, 2022 23:08 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
package runtime
import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"testing"
)
package runtime
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
)
package runtime
import "context"
type API interface {
Execute(ctx context.Context, req Request) (Response, error)
}
type Request struct {
Payload []byte
package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestAdmin(t *testing.T) {
srv := httptest.NewServer(authenticate(adminHandler))
package main
import "net/http"
func main() {
http.HandleFunc("/", publicHandler)
http.HandleFunc("/admin", authenticate(adminHandler))
http.ListenAndServe(":8080", nil)
}
func main() {
var cfg config
if err := envdecode.StrictDecode(&cfg); err != nil {
log.Fatal(err)
}
ctx := contextWithSignals(os.Interrupt)
if err := run(ctx, cfg); err != nil {
log.Fatal(err)
}
package api
type Repository interface {
FetchCode(ctx context.Context, id string) (Code, error)
}
type Runtime interface {
Execute(ctx context.Context, Code) (RuntimeResponse, error)
}
package api
type Server struct {
Repo *Repository
Runtime *Runtime
}
func (s *Server) ExecuteCode(ctx context.Context, req *ExecuteRequest) (*ExecuteResponse, error) {
code, err := s.Repo.FetchCode(ctx, req.ID)
if err != nil {
@cyx
cyx / bundle.js
Last active February 24, 2021 22:46
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(e,t,r){"use strict";var n=r(3),o=Object.prototype.toString;function s(e){return"[