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%'
@cyx
cyx / core.go
Created November 7, 2015 02:28 — forked from apg/core.go
package main
import (
"fmt"
"sync"
)
type Event map[string]interface{}
type asyncStreamFunc func(done <-chan struct{}, in <-chan Event, out chan<- Event)

Generated private key

openssl genrsa -out server.key 2048

To generate a certificate

openssl req -new -x509 -key server.key -out server.pem -days 3650

https

@cyx
cyx / sse.go
Last active August 29, 2015 14:15 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.
// github.com/nu7hatch/gouuid
BenchmarkV4 1000000 1426 ns/op
BenchmarkV5 2000000 910 ns/op
// github.com/streadway/simpleuuid
BenchmarkV5 5000000 689 ns/op
// github.com/tux21b/gocql/tree/master/uuid
BenchmarkRandomUUID 1000000 1470 ns/op
var h = require('mercury').h;
var css = require('./index.css');
var insert = require('insert-css');
module.exports = function component(state) {
insert(css);
return h('.foo')
}
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@cyx
cyx / foo.diff
Created October 3, 2013 01:28 — forked from oren/gist:6803198
diff --git a/tests/models/listing_test.js b/tests/models/listing_test.js
index 14c3d14..c04b7a6 100644
--- a/tests/models/listing_test.js
+++ b/tests/models/listing_test.js
@@ -10,6 +10,7 @@ var dict = {
'Name': 'CPK',
'HeadingText': 'Restaurants',
'PrimaryCollection': 'food',
+ 'Personalization.TotalNotes': '10'
};
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /home/t/nginx/conf/mime.types;
default_type application/octet-stream;