Skip to content

Instantly share code, notes, and snippets.

To implement the PDF generation and streaming functionality on Microsoft Azure, you can use Azure Functions and Azure Blob Storage to store and serve the generated PDF. Here's an example of how you can achieve this:

  1. Create an Azure Storage account and create a Blob container where the generated PDF files will be stored.

  2. Set up an Azure Function App in the Azure portal.

  3. In the Azure Function App, create a new HTTP-triggered function. Choose your preferred language for writing the function code (e.g., JavaScript, C#, etc.).

const countLines = require('./count-lines');
describe('countLines', () => {
test('counts the number of lines in a file', (done) => {
const filename = 'test-file.txt';
const expectedLineCount = 3;
countLines(filename, (err, lineCount) => {
expect(err).toBeNull();
expect(lineCount).toBe(expectedLineCount);
for file in ./app/*.js; do
echo "$(cat copyright.txt)\n$(cat $file)"
done
for file in ./app/*.js; do
echo "$(cat copyright.txt)\n$(cat $file)"
done
@ch4nd4n
ch4nd4n / Filtered.log
Created December 22, 2017 15:24
Spam account creation
2017-12-22T14:29:23.699660+00:00 fwd="108.201.224.150" dyno=web.1 connect=0ms service=40ms status=201 bytes=1056 protocol=https
2017-12-22T14:29:23.665181+00:00 fwd="108.201.224.150" dyno=web.1 connect=0ms service=39ms status=201 bytes=1056 protocol=https
2017-12-22T14:29:23.673962+00:00 fwd="108.201.224.150" dyno=web.2 connect=1ms service=49ms status=201 bytes=1056 protocol=https
2017-12-22T14:29:23.676363+00:00 fwd="108.201.224.150" dyno=web.2 connect=1ms service=50ms status=201 bytes=1056 protocol=https
2017-12-22T14:29:23.620207+00:00 fwd="108.201.224.150" dyno=web.1 connect=0ms service=40ms status=201 bytes=1056 protocol=https
2017-12-22T14:30:22.962434+00:00 fwd="24.40.248.207" dyno=web.1 connect=0ms service=41ms status=201 bytes=1056 protocol=https
2017-12-22T14:30:23.262654+00:00 fwd="24.40.248.207" dyno=web.2 connect=1ms service=44ms status=201 bytes=1056 protocol=https
2017-12-22T14:30:23.237415+00:00 fwd="24.40.248.207" dyno=web.1 connect=0ms service=30ms status=201 bytes=1056 protocol=https
2017-1
@ch4nd4n
ch4nd4n / logger.js
Created June 15, 2017 19:30 — forked from transitive-bullshit/logger.js
winston logger with filename:linenumber
// NOTE: this adds a filename and line number to winston's output
// Example output: 'info (routes/index.js:34) GET 200 /index'
var winston = require('winston')
var path = require('path')
var PROJECT_ROOT = path.join(__dirname, '..')
var logger = new winston.logger({ ... })
// this allows winston to handle output from express' morgan middleware
@ch4nd4n
ch4nd4n / mongoose_promise.js
Created April 3, 2017 13:00
Mongoose Promise Chaining
var mongoose = require('./node_modules/mongoose');
var mongoUrl = process.env.MONGODB_URL;
mongoose.connect(mongoUrl);
var userQuery = {_id: '571874fe45d71e03001059cd'};
var statQuery = {user: '571874fe45d71e03001059cd'};
var models = require('./models');
var results = {};
models.User.find(userQuery).
then(function(doc){
@ch4nd4n
ch4nd4n / replace_email.rb
Created March 4, 2016 08:13
Replace matching email with something else
str = "send your query to my@email.com or to another@provider.com"
matching_regex = /\S+@\S+\.\S+/
replace_with = "******"
str.gsub!(matching_regex, replace_with)
puts str
@ch4nd4n
ch4nd4n / gist:8edb8f066eb22451eeba
Created February 11, 2016 21:13 — forked from levicook/gist:4132037
modeling friends and calculating mutual friends w/ mongodb
// ------------------------------------------------------------------
// Friend collection, where _id is a user.Id and Friends is a list, of user.Id.
// Note: friending and unfriending is a two step operation in this scheme:
> db.friends.find()
{ "_id" : 1, "friends" : [ 2, 3, 4 ] }
{ "_id" : 2, "friends" : [ 1, 3, 5 ] }
{ "_id" : 3, "friends" : [ 1, 2, 4, 5 ] }
{ "_id" : 4, "friends" : [ 1, 3, 5 ] }
{ "_id" : 5, "friends" : [ 2, 3, 4 ] }
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner myScan = new Scanner(System.in);