Skip to content

Instantly share code, notes, and snippets.

@drewcsillag
drewcsillag / JSONExplode.sql
Created Feb 28, 2021
Explode a JSON column to a new table is SQLite
View JSONExplode.sql
-- Create a table that will contain all the JSON object keys
CREATE TABLE KEYS (attrname STRING, expr STRING);
INSERT INTO KEYS
SELECT DISTINCT(e.key), e.fullkey AS key
FROM json_each(log.line) e, log;
-- Generate the CREATE TABLE with all the JSON object keys
.once eval.sql
SELECT 'CREATE TABLE exploded (k_' || group_concat(attrname,' TEXT, k_') || ' TEXT);'
FROM (SELECT attrname FROM keys);
View createtrial.java
final ThreadPoolExecutor experimentExecutor = new ThreadPoolExecutor(
1, 1, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1));
trial = new Trial(
experimentExecutor,
metricRegistry,
"password.succession",
() -> WhichReturn.valueOf(featureService.getFeature("password.succession")),
Trial.IDENTITY_WRAPPER, hibernateWrapper);
View runtrial.java
final Observable<Boolean> result = trial.doTrial(
control, experiment, trialIsEqual, "checkpassword");
View trialresultisequal.java
final IsEqual<TrialResult<Boolean>> trialIsEqual = Trial.makeIsEqual(
bothOrNeitherThrow, passwordCheckIsEqual.pairwiseEqual());
@drewcsillag
drewcsillag / moregeneralisequal.java
Last active Dec 7, 2016
More generalized isEqual
View moregeneralisequal.java
final IsEqual<Boolean> passwordCheckIsEqual = new IsEqual<Boolean>() {
@Override
public boolean apply(final Boolean control, final Boolean experiment) {
final List<String> mismatches = new ArrayList<>();
final IsEqualUtil.MismatchConsumer consumer = IsEqualUtil.consumeToList(
mismatches);
final boolean success = checkNullity(control, experiment, consumer)
&& startCompare(consumer)
.dotEquals(control, experiment, "checkmatches")
.get();
View bothorneitherthrow.java
final IsEqual<Throwable> makeBothOrNeitherThrow = new IsEqual<Throwable>() {
@Override
public boolean apply(final Throwable control, final Throwable experiment) {
final boolean result = ((control == null) == (experiment == null));
if (!result) {
/// log relevant info to Kafka
}
return result;
}
};
@drewcsillag
drewcsillag / controlexperiment.java
Last active Dec 6, 2016
Example of trial framework control and experiment
View controlexperiment.java
final Callable<Observable<Boolean>> control =
() -> oldPasswordCeckingApi.matches(username, password);
final Callable<Observable<Boolean>> experiment =
() -> authService.doPasswordCheck(username, password);
View rebasing-script.txt
[ see https://github.com/drewcsillag/rebaseit ]
[note
gls = git log --format='format:%h : %s'
]
This is a theoretical example based off of real events.
So I'm in my git repo for my project and I start doing work.
Because git is awesome and I do stupid things, I commit *all* the
time. Between refactoring passes and tests passing, I just
commit, because editor undo only goes so far sometimes. Not only
@drewcsillag
drewcsillag / gist:982ace5f3d779b38b953
Last active Aug 29, 2015
revert docker from 1.3.1 to 1.0....
View gist:982ace5f3d779b38b953
sudo apt-get purge lxc-docker lxc-docker-1.3.1
sudo rm -rf /var/lib/docker
sudo sppuppet agent -t -v
@drewcsillag
drewcsillag / gist:1d7f51ec0c17f7237f86
Created Jun 13, 2014
script I have in mind to start kubernetes
View gist:1d7f51ec0c17f7237f86
etcd --name=localkubernetes &
kubelet -etcd_servers=http://localhost:4001 &
apiserver -etcd_servers=http://localhost:4001 machine_list=localhost:10250 &
...more servers here...
echo "Press enter to stop everything>!"
read blah