Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 6, 2024 12:37
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%'
@phil-pedruco
phil-pedruco / data.csv
Last active April 1, 2021 14:14
3D Scatterplot with csv upload
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 9 columns, instead of 8. in line 7.
"V1","V2","V3","V4","V5","V6","V7","V8","V9"
"x1a","y1","z1","x2","y2","z2","x3","y3","z3"
-1.3491290435195,10.1059510260448,-0.411264965906754,-1.21421613916755,6.06357061562689,0.911515840683922,-2.02369356527925,14.1483314364628,-0.451187952584759
1.67610622942448,-28.2861370876445,0.50256601859036,1.50849560648203,-16.9716822525867,0.864538834846784,2.51415934413671,-39.6005919227022,0.581311097123157
1.02121502161026,43.936226125781,0.315348776470193,0.919093519449234,26.3617356754686,0.948975842252453,1.53182253241539,61.5107165760934,0.332304324756775
-4.41415354143828,-37.6643429680954,-0.983110722246539,-3.97273818729445,-22.5986057808573,0.183011769577503,-6.62123031215742,-52.7300801553336,-5.37184425087046
7.45797323063016,16.3056215847584,0.716380879596842,6.71217590756714,9.78337295085503,-0.697709420423757,11.1869598459452,22.8278702186617,-1.02676108223069
-6.40974662732333,-13.3321990741625,-0.903519079437189,-5.768771964591,-7.99931944449751,-0.428547865579768,-9.61461994098499,-18.665078703
@jexp
jexp / bulk-neo4j-import-original.sh
Last active May 10, 2021 20:29
Panama Papers Import Scripts for Neo4j
export NEO4J_HOME=${NEO4J_HOME-~/Downloads/neo4j-community-3.0.1}
if [ ! -f data-csv.zip ]; then
curl -OL https://cloudfront-files-1.publicintegrity.org/offshoreleaks/data-csv.zip
fi
export DATA=${PWD}/import
rm -rf $DATA
@paynoattn
paynoattn / scrollUpDownObservable.ts
Last active June 3, 2018 21:48
Creating an Window scroll up/down Observable
import { Subject } from 'rxJs/Rx';
const body = document.querySelector('body');
let beginningScrollPostion = body.scrollTop,
scrollObserver = new Subject<string>(),
windowEventListender = window.addEventListener('scroll', (scrollEvent) => {
if (body.scrollTop > beginningScrollPostion) {
scrollObserver.next('down');
} else {
scrollObserver.next('up');
// This function is based on the code found at (the original source doesn't work well)
// http://stackoverflow.com/questions/20774648/three-js-generate-uv-coordinate
//
// She following page explains how UV map should be calculated
// https://solutiondesign.com/blog/-/blogs/webgl-and-three-js-texture-mappi-1/
//
// The following documentation shows what a apherical UV map should look like
// https://threejs.org/examples/#misc_uv_tests
var ThreeUvMapper = {
@rflow
rflow / index.html
Last active May 18, 2017 03:38
ReGL circle animation example
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/regl/1.3.0/regl.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.3/chroma.min.js"></script>
<script>
const regl = createREGL();
const doc = document.body;
const docWidth = window.innerWidth;
@jeremyschlatter
jeremyschlatter / Jupyter-React-integration.ipynb
Created July 25, 2017 02:36
Render React inline from a Jupyter notebook cell
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kendricktan
kendricktan / capsule_networks.py
Last active August 17, 2021 17:12
Clean Code for Capsule Networks
"""
Dynamic Routing Between Capsules
https://arxiv.org/abs/1710.09829
"""
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.transforms as transforms
@wKovacs64
wKovacs64 / fixed-width-numbers.css
Created February 15, 2018 21:45
Fixed width numbers CSS
/* https://twitter.com/wesbos/status/932644812582522880/ */
font-feature-settings: "tnum";
font-variant-numeric: tabular-nums;
export const carbonScale = (params = {}) => {
const {
length = 20,
minSize = 10,
intervals = 4,
increment = 2,
transform = v => v
} = params;
const getSize = count => {