Skip to content

Instantly share code, notes, and snippets.

😎
"The impossible is just lack of trying"

Lucas Santos khaosdoctor

😎
"The impossible is just lack of trying"
View GitHub Profile
@khaosdoctor
khaosdoctor / workingwithlucas-en-us.md
Last active Jun 23, 2020
Useful info when working with me
View workingwithlucas-en-us.md

Working with Lucas

Creation Date: June 2020

Status: in progress

A collection of stuff that might come in handy when working with me

My personal philosophy:

@khaosdoctor
khaosdoctor / deno-demo.ts
Last active Jun 2, 2020
Deno Hello World Server
View deno-demo.ts
import { serve } from "https://deno.land/std@0.54.0/http/server.ts"
const handler = serve({ port: 80 })
console.log("Serving at 80")
for await (const req of handler) {
req.respond({ body: "Hello World!\n" })
}
View keybase.md

Keybase proof

I hereby claim:

  • I am khaosdoctor on github.
  • I am khaosdoctor (https://keybase.io/khaosdoctor) on keybase.
  • I have a public key whose fingerprint is 0DAB C1A1 9BD6 DEFA 2EEF DB70 BD08 49CA 3F71 1BD5

To claim this, I am signing this object:

@khaosdoctor
khaosdoctor / index.js
Created Sep 17, 2019
Simple bitcoin-like proof of work using worker threads
View index.js
const { payloads } = require('./payloads.json')
const { Worker } = require('worker_threads')
const LEADING_ZEROES = 4
const final = []
let finishedWorkers = 0
for (let payload of payloads) {
const worker = new Worker('./worker.js', { env: { LEADING_ZEROES } })
worker.once('message', (message) => {
View createFollowerGraph.js
const axios = require('axios')
const n4j = require('neo4j-driver').v1
const qs = require('qs')
const driver = n4j.driver('bolt://localhost:7687', n4j.auth.basic('jsuser', '123456'))
const session = driver.session()
const user = process.env.twitterUser
const secret = process.env.twitterKey
const baseUrl = 'https://api.twitter.com/1.1'
View TypePromise.ts
import { PromiseStates, ResolveFunction, RejectFunction, ExecutorFunction, Nullable } from './types/promiseTypes'
type HandlerFunction = {
onFulfilled: ResolveFunction;
onRejected?: Nullable<RejectFunction>
}
enum ReturnType {
SUCCESS = 'success',
ERROR = 'error'
View start-nodeschool-sp.sh
#!/bin/bash
echo "REMOVING EXISTENT CONTAINERS"
docker stop $(docker ps -qa)
docker rm $(docker ps -qa)
rm -rf ./minimal-nodeschool
rm -rf ./nodeschool-servers
rm config.json
export PUBLIC_IP=`curl https://ipinfo.io/ip`
@khaosdoctor
khaosdoctor / oracleAsyncIterator.js
Created May 23, 2019
Oracle database async iterator to iterate over result sets using for await of
View oracleAsyncIterator.js
class Cursor {
constructor (resultSet) {
this.resultSet = resultSet
}
getIterator () {
return {
[Symbol.asyncIterator]: () => this._buildIterator()
}
}
View promiseAllSettled.js
const promises = [ fetch('index.html'), fetch('https://does-not-exist/') ];
const results = await Promise.allSettled(promises);
const successfulPromises = results.filter(p => p.status === 'fulfilled');
View allSettled1.js
function reflect(promise) {
return promise.then(
(v) => {
return { status: 'fulfilled', value: v };
},
(error) => {
return { status: 'rejected', reason: error };
}
);
}
You can’t perform that action at this time.