Skip to content

Instantly share code, notes, and snippets.

View alexhrescale's full-sized avatar

alex huang alexhrescale

  • Rescale
View GitHub Profile
@alexhrescale
alexhrescale / vnc-shell.sh
Last active November 15, 2024 17:20
nix-vnc-setup
# as of this gist, tigervnc fails to build on the latest nix channel.
# this gist demonstrates using older build to launch it, with openbox
nix-channel --add https://nixos.org/channels/nixos-18.09
nix-channel --update
export DISPLAY=:1
export NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/$USER/channels/nixos-18.09
# for changing the geometry online, see https://stackoverflow.com/a/38630417
case $1 in
@alexhrescale
alexhrescale / alpine-with-admin-user.sh
Created September 23, 2019 16:29
nix package manager from alpine with sudo and admin user
# set up base alpine image
ADMINUSER=$1
if [ ! -e nixos-docker ]; then
git clone https://github.com/NixOS/docker nixos-docker
fi
pushd nixos-docker > /dev/null
git checkout Dockerfile
cp Dockerfile Dockerfile.orig
cat Dockerfile.orig |
sed "s/addgroup/sudo addgroup/" |
@alexhrescale
alexhrescale / default.nix
Last active September 5, 2019 23:31
nix environment for container builders using buildah, podman
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
in stdenv.mkDerivation rec {
name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [
pkgs.buildah
pkgs.conmon
pkgs.podman
@alexhrescale
alexhrescale / default.nix
Last active August 21, 2019 22:51
working jupyter notebook with bash, jupytext, nbextensions (osx + linux), and ExecuteTime + TOC2 enabled by default
# sets up a working jupyter notebook environment with
# - bash kernel support
# - jupyter_nbextensions_configurator with ExecuteTime enabled
# - jupytext
# tested on
# - CentOS, macos using nix==2.2.2
# - docker://ubuntu:latest using nix==2.1.3
# to connect to a remote host via ssh in bash_kernel, use:
# ssh target-hostname -t 'PS1="[PEXPECT_PROMPT>" bash --norc --noprofile'
@alexhrescale
alexhrescale / conda.nix
Created June 17, 2019 21:13
conda nix expression based on v4.3.31 in nixpkgs (force install)
# ref: http://www.jaakkoluttinen.fi/blog/conda-on-nixos/
# ref: https://github.com/NixOS/nixpkgs/blob/af9d10a91b5ef0518ee12b220470735076974210/pkgs/tools/package-management/conda/default.nix
with import <nixpkgs> {};
let
condaDeps = [ stdenv.cc xorg.libSM xorg.libICE xorg.libXrender libselinux ];
extraPkgs = [ which ];
python_version = "2";
conda_version = "4.6.14";
src = fetchurl {
@alexhrescale
alexhrescale / jupyter_trix.py
Last active May 20, 2019 23:21
Jupyter tricks
from IPython.core.display import display, HTML
from lib.renderer import browser as brend
import ipywidgets as widgets
from IPython.display import display
def jupyter_display_table(entries, exclude_headers=None):
headers = list(set([k for entry in entries for k in entry.keys()]))
for hdr in (exclude_headers or []):
headers.remove(hdr)
@alexhrescale
alexhrescale / default.nix
Last active May 3, 2019 22:45
force cpython to default to UCS2, for darwin
{ stdenv, hostPlatform, fetchurl
, bzip2
, gdbm
, fetchpatch
, ncurses
, openssl
, readline
, sqlite
, tcl ? null, tk ? null, tix ? null, xlibsWrapper ? null, libX11 ? null, x11Support ? false
, zlib
@alexhrescale
alexhrescale / dircontentinfo
Last active June 26, 2020 02:07
get directory content information
#!/bin/bash
if [ $# -lt 1 ]; then
cat <<EOF
Usage: $0 <directory> [tabwidth]
This script outputs a table of file information from the contents of <directory> like:
time type perm uid size mime hash path target
4444 file -rw- 0 1111 text/... abcd /x/f
@alexhrescale
alexhrescale / gist:258b7854a4f3e6e73cb372ad46d00d08
Created January 17, 2019 22:48
quick env with virtualenv + override .zshrc + zsh theme + vim_configurable PATH fix
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
in stdenv.mkDerivation rec {
name = "quick";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [
pkgs.python27Packages.virtualenv
@alexhrescale
alexhrescale / default.nix
Last active January 16, 2019 19:24
quick tmux shell env
with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "dev-env";
env = pkgs.buildEnv {
name = name;
paths = buildInputs;
};
buildInputs = [
(vim_configurable.override {