This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#echo '$@ = ' "$@" | |
nixfile="$1"; shift | |
#echo "nixfile =" "$nixfile" | |
outpath="$(nix-build --pure $nixfile)" | |
#echo "outpath =" "$outpath" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#! nix-shell -p "ghc" | |
#! nix-shell -i "runghc" | |
-- https://www.zhihu.com/question/23999095/answer/2254625328 | |
import Control.Monad (guard) | |
brain_states :: (Int, Int) -> [Int] | |
brain_states (x, y) = [z | z <- [x + y, abs(x - y)], z > 0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#! nix-shell shell.nix | |
{ pkgs ? import <nixpkgs> {} }: | |
(pkgs.buildFHSUserEnv { | |
name = "devbox"; | |
targetPkgs = pkgs: (with pkgs; [ | |
python38 | |
python38Packages.pip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-build | |
{ nixpkgs ? (import <nixpkgs> {}) }: with nixpkgs; | |
stdenv.mkDerivation rec { | |
pname = "some-c-project"; | |
version = "0.1"; | |
src = ./.; | |
nativeBuildInputs = [ cmake ]; #replace to your build time dependencies | |
buildInputs = [ libssl ]; #replace to your runtime dependencies | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
phrases = ''' | |
; 希腊字母: 参考 https://en.wikipedia.org/wiki/Greek_alphabet | |
Alpha,1=Α | |
alpha,1=α | |
Nu,9=Ν | |
nu,9=ν | |
Beta,1=Β |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S bash -c 'docker build -t devbox --build-arg USER_ID=$(id -u) --build-arg USER_NAME=$(id -un) --build-arg GROUP_ID=$(id -g) --build-arg GROUP_NAME=$(id -gn) $(realpath $(dirname $0))' | |
FROM ubuntu:20.04 | |
ARG USER_ID | |
ARG USER_NAME | |
ARG GROUP_ID | |
ARG GROUP_NAME | |
RUN addgroup --gid $GROUP_ID $GROUP_NAME; exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#! nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [conduit conduit-extra bytestring text hint])" | |
#! nix-shell -i "ghci -ignore-dot-ghci -fdefer-type-errors -XTypeApplications" | |
{-# language ScopedTypeVariables, TypeApplications, PartialTypeSignatures #-} | |
{-# language OverloadedStrings #-} | |
import Conduit | |
import Data.Conduit | |
import Data.ByteString (ByteString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#So that directories are relative to current file path instead of cwd | |
#Ref: https://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides | |
cd $(dirname $0) | |
cd ./server | |
#Start multiple daemon processes and kill them all in one shot | |
#Ref: https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script | |
(trap 'kill 0' SIGINT EXIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import os | |
relpath = lambda p: os.path.normpath(os.path.join(os.path.dirname(__file__), p)) | |
sys.path.append(relpath('..')) # so that you can import from upper dir | |
path1 = relpath('../src/main.py') | |
print(f'path1 relative to cwd: {path1}') | |
print(f'path1 absolute path: ({ os.path.abspath(path1) })') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# language TemplateHaskell #-} | |
{-# language TypeFamilies #-} | |
{-# language StandaloneDeriving, DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, DeriveDataTypeable, DeriveAnyClass, FlexibleContexts #-} | |
import Control.Monad.Free | |
import Data.Functor.Foldable | |
import Data.Functor.Foldable.TH | |
import Data.Functor.Classes | |
import Text.Show.Deriving | |
import Data.Foldable |