Skip to content

Instantly share code, notes, and snippets.

@aSapien
aSapien / axios_proxy_bypass.md
Last active October 31, 2020 14:54
[axios proxy bypass] #ssrf

Axios proxy bypass

  1. The proxy settings are defined in the top level config.
  2. Upon the initial reqest, an httpAdapter is resolved, and within it, the transport type which can be [http(s) (native), follow-redirect.http, follow-redirect.http].
  • When redirects are disabled, the native http transport is chosen
  • When redirects are enabled, then:
    • No proxy is set: follow-redirect.http
    • An http proxy is set: follow-redirect.http
    • An https proxy is set: follow-redirect.https
  1. follow-redirect has 613 npm packages depending on it. Some popular are axios, tinyreq and node-rest-client.
@aSapien
aSapien / Example.scala
Last active June 10, 2020 10:14
ERROR: Result type in structural refinement may not refer to a user-defined value class
object Example extends App {
/**
* Structural Types
* */
// define a type based on its structure. Doesn't have to be named.
type StructuralToLong = { def toLong: Long }
// Use this type:
def workToLong1(a: StructuralToLong): Long = a.toLong // using named type
@aSapien
aSapien / deepTransform.ts
Created December 9, 2019 13:49
transform a deep object tree
import _ from 'lodash'
// accumulator, value, key, object)
export const transformDeep = (root: object, iteratee: (accumulator: object, nodeOrLeaf: any, key: string, parent: object) => void): object => {
const deepIteratee = (deepAccumulator: object, deepNodeOrLeaf: any, deepKey: string, deepParent: object): void => {
iteratee(deepAccumulator, deepNodeOrLeaf, deepKey, deepParent) //run potential mutation
if (_.isPlainObject(deepNodeOrLeaf) || _.isArray(deepNodeOrLeaf)) { // run deep (maybe shouldRunDeep with eq check?)
import scalaz.zio._
trait Tap[-E1, +E2] {
def apply[R, E >: E2 <: E1, A](effect: ZIO[R, E, A]): ZIO[R, E, A]
}
object Tap {
type Percentage = Int
def make[E1, E2](errBound: Percentage,
@aSapien
aSapien / # octave - 2018-08-11_19-46-09.txt
Created August 11, 2018 16:57
octave on macOS 10.13.6 - Homebrew build logs
Homebrew build logs for octave on macOS 10.13.6
Build date: 2018-08-11 19:46:09
@aSapien
aSapien / code golf.js
Last active August 13, 2018 07:24
[Code Golf Game] The shortest code wins (according to the instructions here: https://grammarly.ai/code-golf/) #challange #game #golf #code
// version 1
z = (k, a, b, c) => (
i = r => k in r[0] ? r[0][k] : r[1],
d = j => Intl.DateTimeFormat('en', { month: 'long' }).format(new Date().setMonth(j)),
f = [[...[,,,,].fill(0.1) ,3.6], 1],
g = [[1,10,5,9,7,3,7,8], 6],
h = [[1,1,2,2,2,2,5,3,3,1], k % 2],
`\nJDK ${ a.toFixed(k > 4 ? 0 : 1) } ${k < 11 ? 'was' : 'will be' } released in ${d(b)} ${c}` + (41 < k ? '' : z(k+1, a + i(f), b + i(g), c + i(h)))
)
@aSapien
aSapien / monorepo-sparse.md
Last active August 13, 2018 07:26
[Working with a monorepo in isolated subrepos] A way to mimic a multi-repo git environment inside a single monorepo #monorepo #git #trick

Clone a monorepo as isolated subrepos

Motivation & Goal

When working on a monorepo, we often create uncommitted changes in multiple "subrepos", which turns into a mess when preparing a commit, when pulling changes from remote, etc...

Git allows us to create a sparse-clone of the monorepo, containing only the subrepo that we are interested in, yet keeping the integrity and functions of a VCS.

For example, we have a monorepo with the following structure (computer@user:~$ tree monorepo):

@aSapien
aSapien / parseq.js
Last active December 3, 2022 13:05
Parallel / Sequential execution control flow with Promises in JS #javascript
export const parallel = (...fs) => sequential(
() => fs.map(f => f()),
Promise.all.bind(Promise));
export const sequential = (f, ...fs) => val => Promise.resolve()
.then(() => f(val))
.then(fs.length ? sequential(...fs) : id => id);
### Feature development Planning Workflow<sup>Functional approach</sup>
In FP, impurity (aka Effects), is handled in a Monadic approach.
This approach enables developers to focus on pure logic implementation and testing, keeping the "Side Effects" on the envelope.
I would like to give a shot to this approach to development planning and time estimations.
The software we are developing is ususlly not self contained. We need to integrate with other software, APIs, Operating Systems, etc...
All those "effectful" aspects, in practice, take an *unknown* amount of time to complete.
This makes our estimation prone to errors, too "flexible" or unprecise, or in some cases "way off".

Keybase proof

I hereby claim:

  • I am asapien on github.
  • I am sapienz (https://keybase.io/sapienz) on keybase.
  • I have a public key ASDqalDydfkpzj6b7eR9ndIeP288fvART4m63ZnIB65s0Ao

To claim this, I am signing this object: