NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.
- Each line is a valid JSON value
- Line separator is ‘\n’
cat test.json | jq -c '.[]' > testNDJSON.json
import requests | |
import urllib.parse | |
from bs4 import BeautifulSoup | |
r = requests.get("https://transparency.entsoe.eu/generation/r2/actualGenerationPerProductionType/show?name=&defaultValue=true&viewType=TABLE&areaType=CTY&atch=true&datepicker-day-offset-select-dv-date-from_input=D&dateTime.dateTime=06.10.2015+00%3A00%7CCET%7CDAYTIMERANGE&dateTime.endDateTime=06.10.2015+00%3A00%7CCET%7CDAYTIMERANGE&area.values=CTY%7C10Y1001A1001A83F!BZN%7C10YDOM-CZ-DE-SKK&productionType.values=B01&productionType.values=B25&productionType.values=B02&productionType.values=B03&productionType.values=B04&productionType.values=B05&productionType.values=B06&productionType.values=B07&productionType.values=B08&productionType.values=B09&productionType.values=B10&productionType.values=B11&productionType.values=B12&productionType.values=B13&productionType.values=B14&productionType.values=B20&productionType.values=B15&productionType.values=B16&productionType.values=B17&productionType.values=B18&productionType.values=B19&dateTime.timezone=CE |
/* | |
Delete duplicated files | |
Naive implementation which consider duplicated files as files with same file size in bytes. | |
Note: this implementation delete *.jpg files but you can easily change it with another regexp. See line 17. | |
*/ | |
import groovy.io.* |
/* | |
Example what happened when you use backslash in Slashy string (https://groovy-lang.org/syntax.html#_slashy_string) | |
Note: there is a note that you are not supposed to do that in https://groovy-lang.org/syntax.html#_special_cases | |
"A consequence of slash escaping is that a slashy string can’t end with a backslash" | |
*/ | |
import groovy.io.* | |
// def dir = new File(/C:\Users/) // WORKS (removed last slash) |
// inject this to your browser's developer tools console | |
(function(console){ | |
console.save = function(data, filename){ | |
if(!data) { | |
console.error('Console.save: No data') | |
return; | |
} | |
if(!filename) filename = 'console.json' | |
if(typeof data === "object"){ | |
data = JSON.stringify(data, undefined, 4) |
NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.
cat test.json | jq -c '.[]' > testNDJSON.json
/* THIS PUZZLER IS SOVLED, SEE REVISION OF THIS GIST TO SEE ORIGINAL PROBLEM */ | |
decimalValue = 9989 | |
hexValue = toHex(code) | |
assert hexValue == '2705' | |
// safe net | |
expectedValue = Integer.toHexString(decimalValue) | |
assert hexValue == expectedValue : "Your impl should work as expected. Result should be: ${expectedValue}" |
// JSON | |
const data = await (await fetch('/my-url')).json(); | |
// Post | |
await fetch('/my-url', { method: 'POST', body: data }); | |
// Request | |
try { | |
const resp = await fetch('/my-url'); | |
// ... |
// methods | |
private static SSLSocketFactory createSslSocketFactory(X509TrustManager trustManager) { | |
try { | |
final SSLContext context = SSLContext.getInstance("TLS"); | |
context.init(null, new TrustManager[]{trustManager}, new SecureRandom()); | |
return context.getSocketFactory(); | |
} catch (NoSuchAlgorithmException | KeyManagementException e) { | |
return ExceptionUtils.rethrow(e); | |
} |
{ echo -e "GET / HTTP/1.0\r\nHost: ftp.gnu.org\r\n\r" >&3; cat <&3 ; } 3<> /dev/tcp/ftp.gnu.org/80 |
const puppeteer = require('puppeteer') | |
const fs = require('fs') | |
// this wrapper means immediatelly execute this code | |
void(async () => { | |
const url = 'https://zbranekvalitne.cz/zbrojni-prukaz/testove-otazky' | |
try { | |
console.log("I am scraping questions from " + url) | |
const browser = await puppeteer.launch({ |