Some random stuff I was messing around with
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 { IncomingMessage, ServerResponse } from 'http' | |
import tracer, { Span } from 'dd-trace' | |
import * as url from 'url' | |
const HTTP_IP = 'http.ip' | |
const HTTP_METHOD = 'http.method' | |
const HTTP_PATH = 'http.uri.path' | |
const HTTP_QUERY = 'http.uri.query' | |
const HTTP_RESPONSE_STATUS = 'http.response.status' | |
const USER_AGENT = 'http.useragent' |
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
### Keybase proof | |
I hereby claim: | |
* I am chronick on github. | |
* I am ndonohuestockx (https://keybase.io/ndonohuestockx) on keybase. | |
* I have a public key whose fingerprint is 8388 F4AF E9A6 6086 06A7 B08F 6656 971C A609 BBE9 | |
To claim this, I am signing this object: |
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
# make all pixels outside the polygon transparent | |
def get_cleaned_img(img, polygon): | |
# convert to numpy (for convenience) | |
imArray = np.asarray(img) | |
# create mask | |
maskIm = Image.new('L', (imArray.shape[1], imArray.shape[0]), 0) | |
ImageDraw.Draw(maskIm).polygon(polygon, outline=1, fill=1) | |
mask = np.array(maskIm) |
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
define(require => { | |
const moment = require('moment'); | |
const d3 = require('d3'); | |
// const parseTime = d3.timeParse('%Y%m%d'); | |
const generateData = () => { | |
let data = []; | |
let n = 1; | |
let planned = 0; |
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 testFuzzy: Test = compare => { | |
// Creates a regex that allows for any number of characters between those | |
// passed. Similar to Sublime Text's cmd-p menu. 'i' for case insensitive. | |
const regex = new RegExp(compare.split("").join(".*"), "i"); | |
return (obj, key) => regex.test(obj[key]); | |
}; |
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 React from 'react'; | |
/* Usage: | |
<FuzzyHighlighter query="some" text="something"/> | |
*/ | |
const FuzzyHighlighter = ({ className, query = '', text = '' }) => { | |
let lastIdx = 0; | |
let tSearch = text.toLowerCase(); | |
const indices = query.toLowerCase().split('') |
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
"use strict"; | |
const _ = require('lodash'); | |
const Prismic = require('prismic.io'); | |
const Promise = require('bluebird'); | |
function exec() { | |
return new Promise((resolve, reject) => { | |
Prismic.api("http://farmlogs-website.prismic.io/api").then(function(api) { | |
return api.query('[[:d = at(document.type, "team-member")]]'); |
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
_setupGeometry: -> | |
map = @props.map | |
map.drawing.disable() | |
map.hideClus() | |
map.hideControls() | |
width = 500 | |
height = 500 |
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
public static Bitmap drawableToBitmap(Drawable drawable) { | |
if (drawable instanceof BitmapDrawable) { | |
return ((BitmapDrawable) drawable).getBitmap(); | |
} | |
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), | |
drawable.getIntrinsicHeight(), | |
Bitmap.Config.ARGB_8888); | |
Canvas canvas = new Canvas(bitmap); |