Skip to content

Instantly share code, notes, and snippets.

View skrater's full-sized avatar

Guilherme Emilio Raduenz skrater

View GitHub Profile
@skrater
skrater / mse_ws_vp8.html
Created May 8, 2017 02:05
Websocket Media Source Extensions
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MSE Demo</title>
</head>
<body>
<h1>MSE Demo</h1>
<div>
<video controls width="80%"></video>
@skrater
skrater / postgres_queries_and_commands.sql
Created October 31, 2018 17:22 — 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%'
@skrater
skrater / lazy-load.js
Created June 5, 2019 00:12
Cloud flare worker lazy load js
addEventListener("fetch", event => {
event.respondWith(handle(event.request));
});
const urls = {
'certificate': 'https://static.eventials.com/evCertificate/assets/ev-certificates.$HASH.js'
}
const hashes = {
'certificate': '79fa861b49cdc1a2f7aa'
# -*- coding: utf-8 -*-
class Topic(object):
_receivers = {}
def __init__(self, topic_name):
self._topic_name = topic_name
def subscribe(self, receiver):
@skrater
skrater / webpack.config.js
Created November 28, 2019 13:11
React webpack config for dev and production build
const { join, resolve } = require('path')
const { main } = require(join(__dirname, 'package.json'))
const TerserPlugin = require('terser-webpack-plugin')
const rules = [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
},
{
use strict;
my $filename = $ARGV[0];
my $line = $ARGV[1];
open my $fh, '<', $filename or die "Can't open file $!";
my $file_content = do { local $/; <$fh> };
my $regex = qr/$line.*?(?=AUTO_INCREMENT=([0-9]+))/sp;
@skrater
skrater / trap_bom.go
Created May 12, 2020 18:17
Seeks UTF-8 BOM before reading CSV
package main
import (
"io"
"bytes"
)
var bom = []byte("\xef\xbb\xbf")
func trapBOM(rws io.ReadWriteSeeker) error {
import re
from collections import Counter
def term_frequency_featurization(texts):
for text in texts:
words = re.findall(r'\w+', text.lower())
yield dict(Counter(words))
def main():
@skrater
skrater / gauge.jsx
Created January 20, 2021 00:27
React SVG Gauge
import React, {useMemo} from 'react';
const GaugeDefaults = {
centerX: 50,
centerY: 50,
};
/**
* Gets cartesian co-ordinates for a specified radius and angle (in degrees)
* @param cx {Number} The center x co-oriinate