This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get data from file m.map | |
# this file has the map sourceName, destName | |
#i.e: | |
#/source/A.jpg,/dest/B.jpg | |
# split with awk and create an array, the use the array to scp | |
for i in $(cat m.map); do A=($(echo ${i}|awk -F"," '{print $1" "$2}'));scp ${A[0]} 1.1.1.1:${A[1]};done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browserify = require('browserify'); | |
var async = require('async'); | |
var heapdump = require('heapdump'); | |
var memwatch = require('memwatch'); | |
// memwatch.on('stats', function(stats) { console.log( stats.usage_trend ) }); | |
// memwatch.on('leak', function(info) { console.log( info ) }); | |
var paths = [ | |
'./views/demo1/demo1.js', | |
'./views/demo2/demo2.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/mitchellh/vagrant/issues/1755 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Detecting which module is causing a global leak can be cumbersome and boring. But there is a nice little trick to find the little bastard. Add these lines at the very beginning of your tests: | |
Object.defineProperty(global, "name_of_leaking_property", { | |
set : function(value) { | |
throw new Error("Found the leak!"); | |
} | |
}) | |
// This will print a stacktrace that shows which module caused the leak. | |
// https://github.com/mochajs/mocha/wiki/Detecting-global-leaks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add Google Chrome for AWS Lambda as dependency in your function. | |
# based on https://github.com/alixaxel/chrome-aws-lambda#aws-lambda-layer | |
nvm use lts/dubnium | |
mkdir -p node_modules/chrome-aws-lambda/ | |
npm install lambdafs@~1.3.0 puppeteer-core@~1.20.0 --no-bin-links --no-optional --no-package-lock --no-save --no-shrinkwrap | |
npm pack chrome-aws-lambda | |
tar --directory node_modules/chrome-aws-lambda/ --extract --file chrome-aws-lambda-*.tgz --strip-components=1 | |
rm chrome-aws-lambda-*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chromium = require( 'chrome-aws-lambda' ); | |
const puppeteer = require( 'puppeteer-core' ); | |
const browser = await puppeteer.launch( { | |
args : chromium.args, | |
defaultViewport : chromium.defaultViewport, | |
executablePath : await chromium.executablePath, | |
headless : chromium.headless, | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = async (event) => { | |
console.log( 'process.traceDeprecation', process.traceDeprecation ); | |
Buffer(1); | |
process.on('warning', (warning) => { | |
console.log( 'stack of deprecation' ); | |
console.log(warning.stack); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
#[async_std::test] | |
async fn index_page() -> tide::Result<()> { | |
use tide::http::{Url, Method, Request, Response}; | |
let mut app = tide::new(); | |
app.at("/").get(|_| async { Ok("Hello, world!") }); | |
let url = Url::parse("https://example.com").unwrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// playground link https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4dc3d523c44e52a90368a3ada41340d5 | |
use std::time::Duration; | |
use std::thread; | |
use std::thread::sleep; | |
use std::sync::{Arc,RwLock}; | |
fn main() { | |
let story_behind_arc = Arc::new( RwLock::new( String::from("Once upon a time..." ))); | |
let story_ref = story_behind_arc.clone(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::future::Future; | |
use std::pin::Pin; | |
use std::task::{Context, Poll}; | |
use std::time::{Duration, Instant}; | |
struct Inspect<F>(F); | |
impl<F: Future> Future for Inspect<F> { | |
type Output = F::Output; |