Skip to content

Instantly share code, notes, and snippets.

View xxczaki's full-sized avatar
🇺🇦
↗️

Antoni Kępiński xxczaki

🇺🇦
↗️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am xxczaki on github.
  • I am xxczaki (https://keybase.io/xxczaki) on keybase.
  • I have a public key ASAZrUUtrcfnMaSJNlhY_-uawXu9eI6STqkolbEz3vNG-wo

To claim this, I am signing this object:

@xxczaki
xxczaki / example.js
Created July 16, 2020 11:14
Embed Changelog Podcast in your React app (works with SSR!)
import React, {useEffect} from 'react';
const Contact = (): JSX.Element => {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://cdn.changelog.com/embed.js'; // or, when hosting the script manually: require('../embed.js');
script.async = true;
script.defer = true;
document.body.append(script);
}, []);
@xxczaki
xxczaki / example.js
Created March 13, 2020 16:35
node-fetch example
const fetch = require("node-fetch");
const convertBody = require("fetch-charset-detection");
fetch("https://somewebsite.com").then(res => {
const text = convertBody(res.buffer(), res.headers);
});
@xxczaki
xxczaki / example.js
Created March 13, 2020 16:30
node-fetch example
const fetch = require('node-fetch');
fetch('https://example.com', {highWaterMark: 10}).then(res => res.clone().buffer());
@xxczaki
xxczaki / example.js
Created March 13, 2020 16:27
node-fetch example
const fetch = require('node-fetch');
fetch('https://example.com').then(res => {
const r1 = res.clone();
return Promise.all([res.json(), r1.text()]).then(results => {
console.log(results[0]);
console.log(results[1]);
});
});
const chalk = require('chalk');
// Czerwone tło
console.log(chalk.bgRed("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
// Pogrubienie
console.log(chalk.bold("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
// Kursywa
console.log(chalk.italic("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
const chalk = require('chalk');
console.log(chalk.hex('#FF0000')("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
console.log(chalk.rgb(123, 45, 67)("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
const chalk = require('chalk');
console.log(chalk.red("Lorem ipsum dolor sit amet, consectetur adipiscing elit."));
console.log("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
@xxczaki
xxczaki / helper.js
Created July 3, 2018 12:50
Simple help message for CLI apps in Node.js
if (arg === '-h' || arg === '--help') {
console.log(`
Commands:
--save, -s Save currencies as default
--help, -h Display help message
--version, -v Display version number
`);
process.exit(1);
}