Skip to content

Instantly share code, notes, and snippets.

View paultag's full-sized avatar

Paul Tagliamonte paultag

View GitHub Profile
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 3, 2024 16:53
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%'
@LocalJoost
LocalJoost / GpsUtils.cs
Last active February 21, 2024 08:07 — forked from govert/GpsUtils.cs
Convert WGS-84 geodetic locations (GPS readings) to Cartesian coordinates in a local tangent plane (Geodetic to ECEF to ENU)
using System;
using System.Diagnostics;
// Some helpers for converting GPS readings from the WGS84 geodetic system to a local North-East-Up cartesian axis.
// The implementation here is according to the paper:
// "Conversion of Geodetic coordinates to the Local Tangent Plane" Version 2.01.
// "The basic reference for this paper is J.Farrell & M.Barth 'The Global Positioning System & Inertial Navigation'"
// Also helpful is Wikipedia: http://en.wikipedia.org/wiki/Geodetic_datum
// Taken from https://gist.github.com/govert/1b373696c9a27ff4c72a
" Place me into after/plugin/fireplace.vim in your Vim directory. Don't overwrite anything!
augroup fireplace_connect
autocmd FileType hy command! -buffer -bar -nargs=*
\ Connect FireplaceConnect <args>
augroup END
function! s:set_up_eval() abort
command! -buffer -bang -range=0 -nargs=? Eval :exe s:Eval(<bang>0, <line1>, <line2>, <count>, <q-args>)
@mechanicalgirl
mechanicalgirl / redvblue_public
Created August 28, 2012 18:01
Playing around with the Sunlight Labs 'openstate' API
"""
This script pulls from the Sunlight Labs "openstates" API
to get information about legislators at the state level,
do a count of their party affiliations,
and return that information as
1) a JSON object for visualizations
2) a table suitable for embed into an HTML page
Information about the specific API used can be found here:
http://python-sunlight.readthedocs.org/en/latest/services/openstates.html
@mnzk
mnzk / fzbz.hy
Last active January 2, 2016 07:09
;; hy-lang fizzbuzz
(import [itertools [count imap]])
(import [pprint [pprint]])
(defn freq [v n]
(->> (* [""] (dec n)) (+ [v])))
(defn fizzbuzz []
(->> (imap (fn [f b n] (or (+ f b) n))
@thomasballinger
thomasballinger / gist:5731729
Last active December 18, 2015 05:19
A section of my vimrc for hy
function! g:Refresh_hy_python_preview()
redir => message
redir END
let pyfile = substitute(bufname("%"), ".hy", "", "") . ".generated.py"
let errfile = substitute(bufname("%"), ".hy", "", "") . ".error"
exec "silent !~/hy/bin/hy2py % > " . pyfile . " 2> " . errfile . " || cat " . errfile . " > " . pyfile
call MyPreviewVSplit(pyfile)
set nomodified
"exec "silent !rm " . pyfile . " " . errfile
redraw!
@olasd
olasd / output
Last active December 15, 2015 20:41
Parsley is fun.
⏚ [nicolasd:~/code/parsley] [parsley] $ python test_parsley.py
('root',
[(1, 0), (346, 0)],
('parens',
[(3, 0), (3, 36)],
('token', [(3, 1), (3, 12)], 'import-from'),
('token',
[(3, 13), (3, 28)],
'tests.resources'),
('token', [(3, 29), (3, 35)], 'kwtest')),
@paultag
paultag / info.md
Last active December 10, 2015 02:09
Hython Runtime

tl;dr

PyPy is ruddy fast. So is Hy.

Time of fib(9), using a simple recursive implementation.

@paultag
paultag / gist:4333969
Created December 19, 2012 02:51
Python in lisp
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all
; copyrightable.
(puts "Hello, World!")
; "Hello, World!"
(import ["os"
"sys"])
@paultag
paultag / gist:4333914
Created December 19, 2012 02:43
frickn' lisp in frickn' python
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all
; copyrightable.
(def hello "World!")
(def square (fn [arg]
(* arg arg)))