Skip to content

Instantly share code, notes, and snippets.

View anwinged's full-sized avatar
👾
oops i did it again

Anton Vakhrushev anwinged

👾
oops i did it again
View GitHub Profile
<?php
/**
* @param string ...$rest
*/
function join_path(...$rest): string
{
if (count($rest) === 0) {
return '';
}
#!/usr/bin/env sh
git diff --shortstat `git hash-object -t tree /dev/null`
#!/usr/bin/env bash
set -eu
git fetch -p
for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
flat_prime_factors :: Integral n => n -> [n]
flat_prime_factors n =
case factors of
[] -> [n]
_ -> factors ++ flat_prime_factors (n `div` (head factors))
where
factors = take 1 $ filter fcb [2 .. int_sqrt n]
fcb x = n `mod` x == 0
int_sqrt = floor . sqrt . fromIntegral
@anwinged
anwinged / Dockerfile
Created March 29, 2019 14:45
Haskell profiling setup
FROM debian:stretch
RUN apt-get update && apt-get install -y ghc ghc-prof
WORKDIR /app
@anwinged
anwinged / show-host-cert
Last active February 11, 2019 11:34
Show host x509 certificate information
#!/usr/bin/env bash
set -eu
HOST=$1
echo | \
openssl s_client -servername $HOST -connect $HOST:443 2>/dev/null | \
openssl x509 -text -noout
#!/usr/bin/env php
<?php
list(, $file, $source) = array_pad($argv, 3, '');
if ($source !== '' && $source !== 'message') {
exit(0);
}
$branch = `git symbolic-ref --short HEAD`;
@anwinged
anwinged / format-changed
Last active September 13, 2018 12:56
Format changed files with php-cs-fixer
#!/usr/bin/env bash
set -eux
# Executable directories
PATH=bin:tools:${PATH}
# Executable