saschazar21's notebooks

  • Transform SVG to PNG - /saschazar21/transform-svg-to-png
    Last edited 3 years ago
    In this notebook, we'll be transforming an SVG-file to the PNG format. First of all, we import 'Sharp' into our notebook. Sharp is a small image library for Node.js, which depends on 'libvips' (which is already pre-installed on most systems out there...)
  • Sitemap parsing of Jekyll-powered sites - /saschazar21/sitemap-parsing
    Last edited 7 years ago
    This script parses the sitemap.xml of different Jekyll-powered sites to show the amount of URLs each websites consists of. The outcome was used for my Thesis presentation at the FH Hagenberg.
  • child_process.exec() - /saschazar21/child-process-exec
    Last edited 7 years ago
    exec() spawns a shell and executes the command within that shell. Any generated output gets buffered. Unlike spawn(), the command is entered as a single string, without any array containing parameters.
  • child_process.spawn() - /saschazar21/child-process-spawn
    Last edited 7 years ago
    spawn() spawns a new process using the given command, with any command line arguments passed into an array. Unlike exec(), no extra shell gets spawned, so that output is not buffered, but caught via event handlers.
  • child_process.fork() - /saschazar21/child-process-fork
    Last edited 7 years ago
    fork() is a special case of spawn(), used exclusively to spawn new Node.js processes. These processes are equipped with their own memory stack and V8 engine, therefore they are as well completely decoupled from the parent process. The only way to communicate with the parent process is done via the built-in communication channel.
  • Diff parsing demo - /saschazar21/diff-parsing-demo
    Last edited 7 years ago
    const parse = require('diffparser'); require('request'); // Sanity check for request-promise below const request = require('request-promise'); // Two commits to be compared const BASE = 'ab39def'; const HEAD = '33715a7'; // https://developer.github.com/v3/repos/commits/#compare-two-commits const API_URL = `https://api.github.com/repos/twbs/bootstrap/compare/${BASE}...${HEAD}`; // Set the options object for request const options = { method: 'GET', url: API_URL, headers: { 'User-Agent': 'Thesis Browser v1.0', // Dummy user agent suffices 'Accept': 'application/vnd.github.v3.diff', // Set correct media type }, }; return request(options) .then(data => { console.log(data); // Raw diff from GitHub console.log(parse(data)); // Parsed diff into JSON });