Skip to content

Instantly share code, notes, and snippets.

@lyndsysimon
lyndsysimon / protonmail_archiver.js
Created Jul 29, 2020
Protonmail inbox cleaner
View protonmail_archiver.js
/* Lyndsy's Protonmail mass archiver
*
* This is a simple script that marks all emails in a folder as
* read and archives them.
*
* I wrote it to work against the Protonmail Beta interface:
* https://beta.protonmail.com
*
* Usage:
* - Navigate to your inbox (or another folder, presumably)
View seriously_arfcom.md

Seriously?!

You just clicked a link to a site that appeared to be on ftc.gov, but it wasn't.

You got lucky this time. I'm not a bad guy - or at least, I'm partial to Arfcommers and wouldn't want to cause trouble for you mangificent bastards. You're safe.

Next time, mouse over the link and make sure that the URL is actually what it claims to be. In most browsers, the URL should appear at the bottom left of the screen when

View keybase.md

Keybase proof

I hereby claim:

  • I am lyndsysimon on github.
  • I am lyndsysimon (https://keybase.io/lyndsysimon) on keybase.
  • I have a public key ASDFr0P2j9lwtB8cDWOcuTZ-G_KoUIXcd8lhH1N3xW6c0Qo

To claim this, I am signing this object:

@lyndsysimon
lyndsysimon / x.rb
Created Sep 6, 2017
Ruby object: hashing public attributes
View x.rb
class MyClass
PUBLIC_ATTRS = [ :alpha, :bravo, :charlie ].freeze
attr_reader *PUBLIC_ATTRS
def to_h
PUBLIC_ATTRS.map do |var|
[var, instance_variable_get("@#{var}")]
end.to_h.with_indifferent_access
end
View gist:dfa513f92d6711f6b55056763ba94f44
class Foo
attr_reader :alpha
def initialize
@alpha = 1
@bravo = 2
end
end
foo = Foo.new
@lyndsysimon
lyndsysimon / domo_negation_filter.md
Last active Mar 21, 2017
Filter Negation using the Domo Analyzer
View domo_negation_filter.md

Problem

Given a list of users and roles, display all users who do not have the admin role.

Existing Behavior

When an aggregation is performed in the card, it happens after the filter is applied. As a result, the row (1, admin) is filtered out, but the row (1, user) is not.

Needed Behavior

View complex.clj
(ns user
(:require [clj-time.core :as t]))
(defn- merge-time
[start m]
(apply hash-map (reduce concat (map (fn [x] [x (merge (x m) {:time (/ (t/in-millis (t/interval start (t/now))) 1000)})]) (keys m)))))
(def data {:first {:message "First message"
:success true}
:second {:message "Second message"
@lyndsysimon
lyndsysimon / example.md
Created Oct 20, 2016
MySQL Column Normalization
View example.md

table source

id first_value second_value
0 0 0
1 0 1
2 1 0
3 1 1

desired output

View gist:516346899bb516d2aa350953e4579136
class MyAPINotAvailable < StandardError
attr_accessor :message
def initialize(message)
@message = "Failed to connect to MyAPI: #{message}"
end
end
raise MyAPINotAvailable.new "Could not update Foo"
View gist:96977376ff5a743b737a3a30b607e6c8
class composable:
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
def __or__(self, other):
return lambda *args, **kwargs: self(other(*args, **kwargs))