Skip to content

Instantly share code, notes, and snippets.

View ORESoftware's full-sized avatar
🏐
Focusing

Alexander Mills ORESoftware

🏐
Focusing
View GitHub Profile
var x = getAStringOrNullWithoutSafety();
if(x != null) {
log.info(x.charAt(0));
}
// end
const getAStringOrNull = (v: Object) : StringOrNull => {
return v === bar ? v.toString() : null;
};
// end
const passAStringOrNull = (v: StringOrNull) => {
return goDoDatabaseStuff(v);
}
// end
const goDoDatabaseStuff = (v: String) => {
return doWhatever();
}
// end
const passAStringOrNull = (v: StringOrNull) => {
if(v == null){
v = "default string";
}
return goDoDatabaseStuff((String)v);
}
// end
@ORESoftware
ORESoftware / null.9.ts
Last active January 17, 2022 22:02
null.
const passAStringOrNull = (v: StringOrNull) => {
let input: String;
if(v == null){
input = "default string";
}
else {
input = v;
}
return goDoDatabaseStuff(input);
@ORESoftware
ORESoftware / lacuna.ts
Last active April 29, 2021 18:41
lacuna stuff
const list = ['a', 'b', 'c', 'c', 'd', 'a', 'b', 'a', 'a', 'd', 'b'];
const findMin = (char1: string, char2: string, arr: Array<string>) : Number => {
let char1Index = -1;
let char2Index = -1;
let min = Number.MAX_SAFE_INTEGER;
for (let i = 0; i < arr.length; i++) {
@ORESoftware
ORESoftware / partitions.md
Created January 4, 2021 04:57
how to create table partitions programmatically (with a loop)

Loop to create partitions does not work b/c a "CREATE TABLE" statement cannot be a prepared statement (laaaame).

do $$
declare
counter integer := 0;
begin
while counter <= 500 loop
    PREPARE create_table(int) AS
 CREATE TABLE mbk_auth_method_$1 PARTITION OF mbk_auth_method FOR VALUES WITH (modulus 500, remainder $1);
@ORESoftware
ORESoftware / partition.md
Created January 4, 2021 00:40
how to partition on user_id, but use modulus, in order to avoid too many partitions?

how do I create partition based on modulus of an id? something like this:

create table my_table(id bigint)
partition by value (modulus(id,1000));

create table my_table_0
partition of my_table
for values in (0);
@ORESoftware
ORESoftware / ovpn.conf
Created December 28, 2020 07:03
openvpn conf to route only certain traffic through VPN is not working :(
client
nobind
dev tun
remote-cert-tls server
remote 35.209.20.300 1194 udp
<key>
-----BEGIN PRIVATE KEY-----