Skip to content

Instantly share code, notes, and snippets.

@guest271314
guest271314 / compiling_standalone.md
Last active April 9, 2024 08:48
Compiling a standalone executable using modern JavaScript/TypeScript runtimes

Compiling a standalone executable using modern JavaScript/TypeScript runtimes

We have the same code working using node, deno, and bun.

E.g.,

bun run index.js
@mb64
mb64 / example.idr
Created November 25, 2020 00:29
All the polymorphism in Idris 2
f : {a : Type} -> a -> a
f {a=Int} x = 2 * x
f {a=String} x = "twice " ++ x
f {a=_} x = x
main : IO ()
main = do
-- Ad-hoc polymorphism type 1: type-based overloading
-- Also in: C++, Java
printLn $ "hi " ++ "there" -- uses the ++ for String
@jperkin
jperkin / trunk-images.md
Last active May 18, 2019 16:02
Test pkgsrc trunk bootstraps and images

pkgsrc trunk packages and images

Now that pkgin has refresh support and the macOS trunk builds have proven that a rolling trunk release works well, I am happy to make SmartOS/illumos trunk packages and images available again for testing.

These are rolling builds of pkgsrc trunk every day (or so), providing the latest packages without having to upgrade across quarterly releases. Just install once then pkgin full-upgrade to keep up-to-date.

This is primarily of interest to:

  • Users who just want the latest software.
  • Users who don't want to bother with having to upgrade releases every quarter.
@vizanto
vizanto / hardware-configuration.nix
Created February 27, 2018 12:03
NixOS 17.03 on SmartOS LX-branded Zone
{ config, lib, pkgs, ... }: with lib;
{
### SmartOS Linux Branded Zone specific configuration
boot.isContainer = true;
boot.loader.initScript.enable = true;
networking.useDHCP = false;
networking.firewall.enable = false;
services.nscd.enable = true;# false;
@ageis
ageis / systemd_service_hardening.md
Last active April 27, 2024 09:46
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@sfan5
sfan5 / alpine-container.sh
Last active April 27, 2024 18:35
bootable systemd-nspawn containers with Linux distributions: Alpine, Arch Linux, Ubuntu
#!/bin/bash -e
# Creates a systemd-nspawn container with Alpine
MIRROR=http://dl-cdn.alpinelinux.org/alpine
VERSION=${VERSION:-v3.19}
APKTOOLS_VERSION=2.14.3-r1
wget_or_curl () {
if command -v wget >/dev/null; then

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@dduvnjak
dduvnjak / add_cloudflare_ips.sh
Last active March 7, 2024 15:18
Add CloudFlare IP addresses to an EC2 Security Group using awscli
# first we download the list of IP ranges from CloudFlare
wget https://www.cloudflare.com/ips-v4
# set the security group ID
SG_ID="sg-00000000000000"
# iterate over the IP ranges in the downloaded file
# and allow access to ports 80 and 443
while read p
do
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@ruslantalpa
ruslantalpa / thoughts.md
Last active October 16, 2015 14:32
Thoughts on SQL backend/resolver for GraphQL server

We want to get back this result

{
	project: {
		id: 1,
		name: "First Project",
		description: "Create a cool website",
		client: {
			id: 1,
			name: "First Client"