Skip to content

Instantly share code, notes, and snippets.

@mravey
mravey / kill.sql
Last active February 1, 2018 13:57
Kill all query running for more than 1 hour on PostgreSQL
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN
SELECT pid
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' AND usename = 'write_1' AND
age(query_start, clock_timestamp()) < -(INTERVAL '1 hour')
ORDER BY age(query_start, clock_timestamp()) ASC
@mravey
mravey / Program.cs
Created July 31, 2013 14:45
Access Bime API in C#
using System;
using System.IO;
using System.Net;
namespace Test
{
class MainClass
{
public static void Main (string[] args)
{
@mravey
mravey / app.js
Created October 30, 2012 21:03
Simple line animation
window.addEventListener('DOMContentLoaded', function() {
d3.selectAll('body > *').remove();
d3.select('body').style('overflow', 'hidden');
var svg = d3.select('body').append('svg')
.attr('height', '100%')
.attr('width', '100%');
var x = d3.scale.linear().domain([0, 100]).range([0, parseInt(svg.style('width'), 10)]);
@mravey
mravey / app.js
Created August 29, 2012 12:39
Change each bar color in Touch Charts
Ext.setup({
onReady: function() {
var data = [];
for (var i = 0; i < 10; i++) {
data.push({
x: i,
y: parseInt(Math.random() * 100)
});
}
@mravey
mravey / output
Created May 4, 2012 12:42
SVG Path Parser
Conflict in grammar: multiple actions possible when lookahead token is DOT in state 25
- reduce by rule: integer_constant -> digit_sequence
- shift token (then go to state 42)
Conflict in grammar: multiple actions possible when lookahead token is DIGIT in state 27
- reduce by rule: digit_sequence -> DIGIT
- shift token (then go to state 27)
Conflict in grammar: multiple actions possible when lookahead token is DIGIT in state 42
- reduce by rule: fractional_constant -> digit_sequence DOT
- shift token (then go to state 27)
@mravey
mravey / app.js
Created April 2, 2012 08:27
Draw a line from one item point to another
Ext.setup({
onReady: function() {
var data = [];
for (var i = 0; i < 10; i++) {
data.push({
x: i,
y: parseInt(Math.random() * 100, 10)
});
}
@mravey
mravey / app.js
Created March 29, 2012 12:53
Label renderer Touch Charts
Ext.setup({
onReady: function() {
var chart = new Ext.chart.Chart({
store: new Ext.data.JsonStore({
fields: ['month', 'salary'],
data: [{
month: 'January',
salary: 800
}, {
month: 'February',