This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select delete_job(job_id) from timescaledb_information.jobs where job_id >=1000; | |
drop table conditions cascade; | |
CREATE TABLE conditions ( | |
time TIMESTAMPTZ NOT NULL, | |
device INTEGER NOT NULL, | |
temperature FLOAT NOT NULL | |
); | |
SELECT * FROM create_hypertable('conditions', 'time'); | |
INSERT INTO conditions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE ticks CASCADE; | |
DROP TABLE ohlc_1s CASCADE; | |
CREATE TABLE ticks ( time TIMESTAMP NOT NULL, symbol varchar, price decimal, volume int); | |
CREATE TABLE ohlc_1s ( time TIMESTAMP NOT NULL, symbol varchar, o decimal, h decimal, l decimal, c decimal, v int); | |
SELECT create_hypertable('ticks', 'time'); | |
SELECT create_hypertable('ohlc_1s', 'time'); | |
CREATE OR REPLACE FUNCTION feed_ohlc_1s() RETURNS trigger AS | |
$BODY$ | |
DECLARE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem "activerecord", "~> 6.1" | |
gem "composite_primary_keys", "~> 6.0" | |
gem "pg", "~> 1.2" | |
gem 'pry' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem "activerecord", "~> 6.1" | |
gem "composite_primary_keys", "~> 6.0" | |
gem "pg", "~> 1.2" | |
gem 'pry' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table batteries cascade; | |
CREATE TABLE batteries ( time timestamp not null, batt_uid varchar, charge int, delta int); | |
SELECT create_hypertable('batteries', 'time'); | |
CREATE OR REPLACE FUNCTION update_delta() RETURNS trigger AS | |
$BODY$ | |
DECLARE | |
previous_charge integer; | |
BEGIN | |
select charge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION classify(anyelement) | |
RETURNS text[] AS $$ | |
SELECT ARRAY_REMOVE(ARRAY[ | |
CASE WHEN $1 ~ '[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+' THEN 'email' END, | |
CASE WHEN $1 ~ '(https?://|www\\.)' THEN 'link' END | |
], NULL) | |
$$ | |
LANGUAGE SQL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'drb/drb' | |
SERVER_URI="druby://localhost:8787" | |
# Start a local DRbServer to handle callbacks. | |
# | |
# Not necessary for this small example, but will be required | |
# as soon as we pass a non-marshallable object as an argument | |
# to a dRuby call. | |
# | |
# Note: this must be called at least once per process to take any effect. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all shortcut with comments | |
Fast.shortcut :shortcuts do | |
fast_files.each do |file| | |
lines = File.readlines(file).map{|line|line.chomp.gsub(/\s*#/,'').strip} | |
result = capture_file('(send _ :shortcut $(sym _) ...)', file) | |
result = [result] unless result.is_a?Array | |
result.each do |capture| | |
target = capture.loc.expression | |
puts "fast .#{target.source[1..-1].ljust(30)} # #{lines[target.line-2]}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crossed_words size = 20 | |
words = %w[jonatas aline lorenzo lucas | |
joao juca pedro mariana | |
pedroca joana bartolomeu | |
maria louise ana carol luiza salete rafael leandro] | |
matrix = (0..size).map{|_|['.']*size} | |
n = 0 | |
while words.any? | |
word = words.sort_by(&:size).last | |
orientation = ['vertical', 'horizontal'].sample |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pathspec', require: 'pathspec' | |
gem 'pry' | |
end | |
module CodeownersToDatabase |