I hereby claim:
- I am walerian777 on github.
- I am walerian (https://keybase.io/walerian) on keybase.
- I have a public key whose fingerprint is 0BA8 BCC6 458A D0E9 6AD1 E5C4 F91A 4E1F 0952 255B
To claim this, I am signing this object:
-- This function inserts a copy of an existing row (with primary key equal to `_id`) into a table called `_tbl`. | |
-- Returns a `row_id` which is a primary key of the new row. | |
CREATE OR REPLACE FUNCTION copy_row_from_table(_tbl regclass, _id uuid, OUT row_id uuid) AS | |
$func$ | |
BEGIN | |
EXECUTE ( | |
SELECT format('INSERT INTO %1$s(%2$s) SELECT %2$s FROM %1$s WHERE id = $1 RETURNING id', | |
_tbl, string_agg(quote_ident(attname), ', ')) | |
FROM pg_attribute |
-- This function transfers all rows from tables which contains `_scope_column_name` AND `_update_column_name`, | |
-- whose value in a column called `_scope_column_name` is equal to `_scope_column_value`, | |
-- by updating the value of `_update_column_name` with `_update_column_value`. | |
-- Finally, it updates `_update_column_name` with `_update_column_value` in the record from `_scope_table_name` table, | |
-- where primary key is equal to `_scope_column_value`. | |
CREATE OR REPLACE FUNCTION transfer_tables(_scope_table_name regclass, _scope_column_name text, _scope_column_value uuid, _update_column_name text, _update_column_value uuid) | |
RETURNS void AS | |
$func$ | |
DECLARE |
_ = require('lodash') | |
PasswordGenerator = (length = 20) -> | |
_.map(_.shuffle(_.range(length)), (n) -> | |
switch n % 3 | |
when 0 # A digit | |
Math.floor(Math.random() * 9).toString() | |
when 1 # A lowercase letter | |
String.fromCharCode(Math.floor(Math.random() * 26) + 97) | |
when 2 # An uppercase letter |
I hereby claim:
To claim this, I am signing this object:
require 'digest' | |
class ChristmasDraw | |
attr_accessor :names | |
def initialize(names) | |
@names = names | |
end | |
def call |
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | |
interface HeadersObject { | |
[key : string] : string | |
} | |
interface FetcherResponse { | |
data : object, | |
headers : HeadersObject | |
} |
def csv_dump(relation:, file_path: nil) | |
file_path ||= "#{relation.table.name}.csv" | |
CSV.open(file_path, 'wb') do |csv| | |
csv << relation.klass.attribute_names | |
relation.each do |record| | |
csv << record.attributes.values | |
end | |
end | |
end |