Skip to content

Instantly share code, notes, and snippets.

View akhal3d96's full-sized avatar

Ahmed Ayoub akhal3d96

View GitHub Profile
ls -a |\
grep -E "^\.(.)+~$" |\
xargs -I {} ls -l {} |\
awk {'print $5'} |\
paste -sd+ |\
bc
@akhal3d96
akhal3d96 / pipe.js
Last active August 8, 2020 15:22
pipe(fn1, fn2, f3)(data) == fn1(fn2(fn3(data)))
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x)
@akhal3d96
akhal3d96 / shuffle.js
Created August 15, 2020 16:44
Shuffle a Javascript Array
/**
* Randomize the order of the elements in a given array.
* source: https://github.com/pazguille/shuffle-array/blob/master/dist/shuffle-array.js
* @param {Array} arr - The given array.
* @returns {Array}
*/
export function shuffle (arr) {
if (!Array.isArray(arr)) {
throw new Error('shuffle expect an array as parameter.')
}
@akhal3d96
akhal3d96 / .prettier.json
Created February 2, 2021 13:23
My prettier configuration
{
"singleQuote": true,
"semi": false,
"trailingComma": "none"
}
@akhal3d96
akhal3d96 / jenkins-docker-did.yml
Created October 4, 2021 12:12
Jenkins with Docker In Docker
version: "3.9"
services:
jenkins-docker:
image: docker:dind
privileged: true
volumes:
- jenkins-docker-certs:/certs/client
- jenkins_home:/var/jenkins_home
# pool_size: number of threads
# jobs: A queue (See: https://rubyapi.org/3.0/o/queue)
def thread_pool(pool_size: 4, jobs:, &block)
threads = []
results = []
mutex = Mutex.new
pool_size.times do
threads << Thread.new do
while !jobs.empty? do