This file contains 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
{% test enum_distribution(model, column_name, expected, allow_other=False, fudge=0.1) %} | |
SELECT | |
COALESCE(expected.enum_val, actual.enum_val) AS enum_val, | |
expected.fraction AS expected_fraction, | |
actual.fraction AS actual_fraction | |
FROM ( | |
{% for enum_val, expected_fraction in expected.items() -%} | |
SELECT '{{enum_val}}' AS enum_val, {{expected_fraction}} AS fraction | |
{%- if not loop.last %} UNION ALL {% endif %} |
This file contains 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
from typing import Any, TYPE_CHECKING, Dict | |
import prefect | |
from prefect import Task, Flow | |
from prefect.triggers import all_successful | |
from prefect.tasks.control_flow.conditional import CompareValue | |
from prefect.engine import signals | |
if TYPE_CHECKING: | |
from prefect.engine import state # noqa | |
from prefect import core # noqa |
This file contains 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
const { STRIPE_PUBLIC_KEY } = process.env, | |
axios = require("axios"), | |
qs = require("querystring").stringify, | |
{ JSDOM } = require("jsdom"); | |
module.exports.simulateAction = async function( | |
intentId, | |
clientSecret, | |
mode = "setup_intent" | |
) { |
This file contains 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
/* | |
Unlike findOneAndUpdate, this returns both the old and the new docs, | |
the operation is performed atomically. | |
Note that although it can apply defaults properly, it does not apply | |
pre-update hooks, with the exception of timestamps (see note in code). | |
Example: | |
Dogs.upsert({owner: 'wallace', name: 'grommit'}, {breakfast: 'eggs'}) |
This file contains 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
// For info on usage, development and debugging, | |
// see https://docs.google.com/a/landtech.co/document/d/1eB2oH3d7mpDfK8gxTiYphxPgBM7EDu5MeUNKrQwYIrQ/ . [private] | |
const Painter = require('./render/painter'), | |
Style = require('./style/style'), | |
EXTENT = require('./data/extent'), | |
Evented = require('./util/evented'), | |
TileCoord = require('./source/tile_coord'), | |
mat4 = require('@mapbox/gl-matrix').mat4, | |
Source = require('./source/source'), |
This file contains 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
/* | |
Example basic usage is something like this: | |
<div id="vue-mount"> | |
<vue-fetch endpoint="/example" :id="exampleId" :model="exampleModel"></vue-fetch> | |
{{exampleId}} {{exampleModel.thing}} {{exampleModel.other}} | |
</div> | |
<script> | |
new Vue({ | |
el: "#vue-mount" |
This file contains 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
""" | |
pip install | |
Download pyhook .whl file from: | |
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook | |
Note if you have python 2.7, and 64 bit you need the version: | |
"pyHook-1.5.1-cp27-none-win_amd64.whl" | |
otherwise choose the relevant one. | |
Then open a comand prompt, cd to your downloads folder and run |
This file contains 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
/* | |
Go to https://driverpracticaltest.direct.gov.uk, and get to the | |
"Test time" section. Then, open the F12 developer console, and copy paste | |
all of the following code. If something breaks, then just refresh the page and | |
try again. You can modify the configuration below. | |
Currently date parsing is rather basic, we just get the day for a specific target month, | |
e.g. May 2016, and then check if that day (e.g. 23rd) is before or equal to the day you | |
requested. It's not hard to improve upon this but I haven't bothered. |
This file contains 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
% sample data | |
s1 = 8192; s2 = 200; | |
img_a = rand(s1, s2); | |
img_b = rand(s1, s2); | |
r = 2; | |
% and the calculation itself | |
img_diff = img_a - img_b; | |
kernel = bsxfun(@plus, (-s1:s1).^2', (-s2:s2).^2); | |
kernel = 1/(2/pi/r^2) * exp(-kernel/ (2*r*2)); |
This file contains 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
import timeit | |
import matplotlib.pylab as plt | |
pow2s = arange(10,22,0.25) | |
t_times1 = np.zeros(len(pow2s)) | |
t_sum = np.zeros(len(pow2s)) | |
t_cumsum = np.zeros(len(pow2s)) | |
for ii, pow2 in enumerate(pow2s): | |
setup = "import numpy as np\na = np.random.rand({})".format(2**pow2) | |
t_times1[ii] = min(timeit.Timer('a*1.0', setup=setup).repeat(3, 100))/100 |
NewerOlder