This file contains hidden or 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 sklearn.metrics.pairwise import pairwise_distances | |
import numpy as np | |
# X shoudl be a numpy matrix, very likely sparse matrix: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.html#scipy.sparse.csr_matrix | |
# T1 > T2 for overlapping clusters | |
# T1 = Distance to centroid point to not include in other clusters | |
# T2 = Distance to centroid point to include in cluster | |
# T1 > T2 for overlapping clusters | |
# T1 < T2 will have points which reside in no clusters | |
# T1 == T2 will cause all points to reside in mutually exclusive clusters |
This file contains hidden or 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
function declareWinner() public onlyOwner { | |
if (charity1Votes == charity2Votes) { | |
winner = 'Charity #1 and #2 tied!'; | |
} | |
if (charity1Votes > charity2Votes) { | |
winner = 'Charity #1 won!'; | |
} | |
if (charity1Votes > charity2Votes) { |
This file contains hidden or 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
let item1Votes | |
try { | |
item1Votes = parseInt(responses[0].data.rows[0].metricValues[0].value) | |
} catch { | |
item1Votes = 0 | |
} | |
let item2Votes | |
try { | |
item2Votes = parseInt(responses[1].data.rows[0].metricValues[0].value) |
This file contains hidden or 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 requestConfig = { | |
method: 'post', | |
headers: { | |
"Authorization": `Bearer ${accessToken}`, | |
"Accept": 'application/json', | |
"Content-Type": 'application/json' | |
}, | |
data: { | |
"metrics": [{"name":"activeUsers"}], | |
"minuteRanges":[{"startMinutesAgo":29,"endMinutesAgo":0}] |
This file contains hidden or 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 tokenResponse = await Functions.makeHttpRequest({ | |
url: 'https://oauth2.googleapis.com/token', | |
method: 'post', | |
data: jwtRequestString | |
}) | |
const accessToken = tokenResponse.data.access_token |
This file contains hidden or 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
CREATE TEMP FUNCTION | |
KECCAK256(data STRING) | |
RETURNS STRING | |
LANGUAGE js AS """ | |
var utf8 = unescape(encodeURIComponent(data)); | |
var arr = []; | |
for (var i = 0; i < utf8.length; i++) { | |
arr.push(utf8.charCodeAt(i)); | |
} | |
return ethers.utils.keccak256(arr) |
This file contains hidden or 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
CREATE TEMP FUNCTION | |
KECCAK256(data STRING) | |
RETURNS STRING | |
LANGUAGE js AS """ | |
var utf8 = unescape(encodeURIComponent(data)); | |
var arr = []; | |
for (var i = 0; i < utf8.length; i++) { | |
arr.push(utf8.charCodeAt(i)); | |
} | |
return ethers.utils.keccak256(arr) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
CREATE TEMP FUNCTION | |
hex64ToInt64(hex STRING) | |
RETURNS INT64 AS ( | |
IF(hex < "8000000000000000", | |
cast(concat("0x", hex) AS INT64), | |
(SELECT (((ms32 & 0x7fffffff) << 32) | ls32) - 0x7fffffffffffffff - 1 | |
FROM (SELECT cast(concat("0x", substr(hex, 1, 8)) AS INT64) AS ms32, | |
cast(concat("0x", substr(hex, 9, 8)) AS INT64) AS ls32)))); | |
CREATE TEMP FUNCTION | |
KECCAK(data STRING) |
This file contains hidden or 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
CREATE TEMP FUNCTION term_years(term STRING) | |
RETURNS ARRAY<STRUCT<year INT64, term_frequency INT64>> AS ( | |
( | |
SELECT years | |
FROM `gcp-pdp-words-dev.sandbox.eng_bert_preprocessed_year_term_frequencies` | |
WHERE preprocessed_term = term | |
) | |
-- SELECT ARRAY_AGG(STRUCT<year INT64, term_frequency INT64>(z.year, z.term_frequency + IFNULL(t.term_frequency, 0))) | |
-- FROM | |
-- ( |
NewerOlder