Skip to content

Instantly share code, notes, and snippets.

@FlyInk13
FlyInk13 / snake.js
Last active March 25, 2021 13:29
Отрисовка змейки на node/canvas и стриминг ВКонтакте через ffmpeg. (Для запуска нужен токен VK Live https://vk.cc/6njXbx)
const https = require('https');
const fs = require('fs');
const { spawn } = require('child_process');
const { Image, createCanvas } = require('canvas');
const VK = require('VK-Promise');
const canvas = new createCanvas(1280, 720);
const streamer = VK(""); // https://vk.cc/6njXbx
const request = streamer.request;
const ctx = canvas.getContext('2d');
const fps = 30;
@tanaikech
tanaikech / submit.md
Last active November 15, 2024 13:51
Multipart-POST Request Using Node.js

Multipart-POST Request Using Node.js

Here, I introduce 2 scripts for uploading files to Slack using Node.js as samples. These 2 sample scripts are for uploading files to Slack.

Sample script 1:

  • You can upload the zip file by converting byte array as follows.
    • At first, it builds form-data.
    • Adds the zip file converted to byte array and boundary using Buffer.concat().
    • This is used as body in request.
@innermond
innermond / pdfimage
Last active October 13, 2022 10:23
Extract images from pdf but, surprise! The images that contain alpha channels are extracted as two images. The source and the mask, as they are stored inside pdf file. This script recombine them into an one png file with given transparency
#/usr/bin/bash
# extract images from pdf at first-hand
#prefix=pict
#echo extract images from "$1"
#pdfimages -j "$1" $prefix
# IMAGES ARE SAVED SECVENTIALLY AS IMAGE AND THE NEXT IS A MASK IMAGE !!!!
declare -a files=($(ls *.ppm *.pbm))
mask=
image=
for (( i = 0; i < ${#files[*]}; i = i + 2 ))