Skip to content

Instantly share code, notes, and snippets.

@stormoz
stormoz / axios_get_pipe_zip.js
Created July 25, 2019 13:29 — forked from bhuizi/axios_get_pipe_zip.js
axios get request w/ piping
const axios = require('axios');
const fs = require('fs');
const url = <path_to_file>
axios({
method: 'get',
url: url,
responseType:'stream'
})
.then(res => {
res.data.pipe(fs.createWriteStream('new.zip'));
@stormoz
stormoz / read data to stream
Created July 25, 2019 13:19
read data to stream
import http from 'http';
import axios from 'axios';
http.createServer(async function (req, res) {
const responseStream = await axios({
method: 'get',
url: 'http://blob.file.storage/filepath',
responseType: 'stream'
});
@stormoz
stormoz / gist:93eaa11b846ae413eaf374482842a72d
Last active March 8, 2019 02:19
Node JS: send binary file as multiform data
var formData = {
'myfile_key': {
value: <Buffer object>
options: {
filename: 'image_file'
}
}
};
function callAsync(fn) {
// get iterator
var iterator = fn();
// used as a callback to currently yielded functions
function next() {
// get next function
var current = iterator.next();
// recursion exit condition
function callAsync(fn) {
// get iterator
var gen = fn();
// used as a callback to currently yielded functions
function next() {
// get next function
var ret = gen.next();
// recursion exit condition
var Lazy = function (getFunc) {
var _value;
return {
get value() {
if(!_value){
_value = getFunc();
}
return _value;
@stormoz
stormoz / configure kdiff tree
Created January 18, 2016 02:15
configure kdiff tree
#from http://stackoverflow.com/questions/6412516/configuring-diff-tool-with-gitconfig
[difftool "kdiff3"]
path = C:/Progra~1/KDiff3/kdiff3.exe
trustExitCode = false
[difftool]
prompt = false
[diff]
tool = kdiff3
[mergetool "kdiff3"]
@stormoz
stormoz / inline css gulp task
Created January 18, 2016 01:06
inline css gulp task
gulp.task('inline', function () {
console.log('Inline css');
return gulp.src(config.build + "index.html")
.pipe(replace(/\<link .*?href=["']css\/styles\.css["'].*?[\/]{0,1}\>/, function(s) {
var style = fs.readFileSync(config.build + "css/styles.css", 'utf8');
return '<style>\n' + style + '\n</style>';
}))
.pipe(gulp.dest(config.buildDir));
});
@stormoz
stormoz / install.bat
Last active February 10, 2022 08:57
Start Selenium Grid hub and nodes as Windows services
nssm install SeleniumHub java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role hub
nssm start SeleniumHub
nssm install SeleniumNode1 java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe
nssm set SeleniumNode1 DependOnService SeleniumHub
nssm start SeleniumNode1
nssm install SeleniumNode2 java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe
nssm set SeleniumNode2 DependOnService SeleniumHub
nssm start SeleniumNode2
using System;
using NUnit.Framework;
using Shouldly;
namespace IoC.Site.Tests.ParallelTests
{
//Maybe monad
public sealed class Maybe<T> where T : class
{
private readonly T _value;