Skip to content

Instantly share code, notes, and snippets.

View Horaddrim's full-sized avatar
👽
Seeking knowledge...

Horaddrim Horaddrim

👽
Seeking knowledge...
  • C-137
View GitHub Profile
// database.js
const MongoClient = require('mongodb').MongoClient;
async function getConnection(server) {
return await MongoClient.connect(server);
}
/**
* @param {MongoClient} client - MongoClient instance!
* @param {String} databaseName - The database name string
function getSomething() {
return new Promise((resolve, reject) => setTimeout(() => resolve('Something'), 3000));
}
function getAnotherThing() {
return new Promise((resolve, reject) => setTimeout(() => resolve('Another thing'), 4000));
}
function anotherMain() {
return Promise.all([
const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');
// Connection URL
const url = 'mongodb://localhost:27017';
// Database name
const dbName = 'myproject';
(async function() {
try {

Version 10.0.0

  • Assert
    • Calling assert.fail() with more than one argument is deprecated. [70dcacd710]
    • Calling assert.ok() with no arguments will now throw. [3cd7977a42]
    • Calling assert.ifError() will now throw with any argument other than undefined or null. Previously the method would throw with any truthy value. [e65a6e81ef]
    • The assert.rejects() and assert.doesNotReject() methods have been added for working with async functions. [599337f43e]
  • Async_hooks
    • Older experimental async_hooks APIs have been removed. [1cc6b993b9]
  • Buffer
wget https://s3.amazonaws.com/assets.minecraft.net/pi/minecraft-pi-0.1.1.tar.gz .
tar zxvf minecraft-pi-0.1.1.tar.gz
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl
export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
mkdir $HOME/.kube || true
touch $HOME/.kube/config
// Primeiro você precisa rodar npm i esprima escodegen
const escodegen = require('escodegen');
const parser = require('esprima');
const fs = require('fs');
function processAst(astBody) {
let currentElement;
// Se esse elemento passado ainda não for o body da Arvore de Sintaxe Abstrata,
// Chamamos a função recursivamente para pegar o body real;
import os
import fnmatch
def gen_find(filepat,top):
for path, dirlist, filelist in os.walk(top):
for name in fnmatch.filter(filelist,filepat):
yield os.path.join(path,name)
# Example use
const axios = require('axios');
module.exports = function(context, blob, outputBlob) {
context.log(blob);
axios.post(
'https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=pt-BR&format=detailed',
blob,
{
headers: {
'Ocp-Apim-Subscription-Key': process.env.API_KEY,
# Import from this wonderful lib the constant equals to the Jupiter Mass (in KG)
from astropy.constants import M_jup
# if you don't want the library
# M_jup = 10**27
def mj_to_kg(mj_value):
raw_value = int(mj_value)
return (raw_value + 0.00019) * M_jup