A Pen by Aaron Harris on CodePen.
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
type Post { | |
id: ID! | |
title: String! | |
title2: String! | |
} | |
type Query { | |
# Get a single value of type 'Post' by primary key. | |
singlePost(id: ID!): Post | |
@deprecated(reason: "Use localization field instead") |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css"/> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
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
import { pipeline, PassThrough, TransformCallback, Transform } from 'stream/promises'; | |
import { createGunzip } from 'zlib'; | |
import * as csv from 'csv-parser'; | |
import * as S3 from 'aws-sdk/clients/s3'; | |
const s3client = new S3({ maxRetries: 15, httpOptions: { timeout: 15 * 60_000 } }); | |
async function main(bucketName, dataKey) { | |
const s3Stream = s3client.getObject({ Bucket: bucketName, Key: dataKey}).createReadStream() | |
.on('error', err => { console.error('S3 read error:', err); }); // errors from S3 service | |
const unzipStream = createGunzip() |
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
// remove everything forbidden by XML 1.0 specifications, plus the unicode replacement character U+FFFD | |
const INVALID_XML_REGEX = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g; | |
// remove everything discouraged by XML 1.0 specifications | |
const DISCOURAGED_XML_REGEX = new RegExp( | |
'([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|(?:\\uD83F[\\uDFFE\\uDFFF])|(?:\\uD87F[\\uDF' + | |
'FE\\uDFFF])|(?:\\uD8BF[\\uDFFE\\uDFFF])|(?:\\uD8FF[\\uDFFE\\uDFFF])|(?:\\uD93F[\\uDFFE\\uD' + | |
'FFF])|(?:\\uD97F[\\uDFFE\\uDFFF])|(?:\\uD9BF[\\uDFFE\\uDFFF])|(?:\\uD9FF[\\uDFFE\\uDFFF])' + | |
'|(?:\\uDA3F[\\uDFFE\\uDFFF])|(?:\\uDA7F[\\uDFFE\\uDFFF])|(?:\\uDABF[\\uDFFE\\uDFFF])|(?:\\' + | |
'uDAFF[\\uDFFE\\uDFFF])|(?:\\uDB3F[\\uDFFE\\uDFFF])|(?:\\uDB7F[\\uDFFE\\uDFFF])|(?:\\uDBBF' + | |
'[\\uDFFE\\uDFFF])|(?:\\uDBFF[\\uDFFE\\uDFFF])(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\' + |
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
/** | |
* Nested grouping of a list of objects by multiple nested keys | |
* Unwraps groupByAll(['dataset_name', 'table_name', 'column_name']) to something like: | |
* | |
* ``` | |
* _.flow( | |
* _.groupBy('dataset_name'), | |
* _.mapValues(_.groupBy('table_name')), | |
* _.mapValues(_.mapValues(_.groupBy('column_name'))) | |
* ) |
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
#include <stdio.h> | |
int main() | |
{ | |
int num1 = 0, num2 = 0, res1 = 0, res2 = 0; | |
printf("\nEnter num %% num: "); | |
scanf("%d %d", &num1, &num2); | |
res1 = num1 % num2; | |
res2 = num1 / num2; |
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
read -p "Enter a string: " string | |
if [[ $(rev <<< $string) == "$string" ]]; then | |
echo Palindrome | |
fi | |
kcurl -s -o /dev/null -I -w "%{http_code}" https://cr.amazon.com/r/$FOO | |
curl -s http://www.example.com | sed -e 's#<!doctype.*##gm' | xpath '/html/body/div/h1/text()' | |
crlink=`kcurl -s https://cr.amazon.com/r/ | xmllint --html --xpath 'string(//*[@id="datagrid-0"]/div[2]/table/tbody/tr[1]/td[2]/a/@href)' 2>/dev/null -` | |
cr=${latestcr//[\/r]/} |
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 getBytes(string) { | |
return Buffer.byteLength(String(string), 'utf8'); | |
} | |
function trimToBytes(string, diff) { | |
return Buffer.alloc(diff, string, 'utf8').toString(); | |
} | |
// This is only intended atm for flat objects with string values | |
// Does not handle edge cases |
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
var proxy, handler; | |
handler = { | |
has(/*target, prop*/) { | |
return false; | |
}, | |
get(target, prop, receiver) { | |
if (prop in target) return target[prop]; | |
return receiver; | |
}, | |
set(/*target, prop, value, receiver*/) { |
NewerOlder