Skip to content

Instantly share code, notes, and snippets.

View candeira's full-sized avatar

Javier Candeira candeira

View GitHub Profile
@candeira
candeira / README
Created July 6, 2022 07:51 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Let's get started
#
# Let's install nix (at the time of writing this is version 2.5.1
curl -L https://nixos.org/nix/install | sh
# I might not have needed to, but I rebooted
@candeira
candeira / direnvrc
Created August 9, 2021 23:00
layout_poetry for direnv
# Layout Poetry originally from
# https://github.com/direnv/direnv/issues/592
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to cr
exit 2
fi
local VENV=$(poetry env list --full-path | cut -d' ' -f1)
@candeira
candeira / ubuntu-ec2-init.sh
Created June 27, 2021 01:08 — forked from ned2/ubuntu-ec2-init.sh
A Bash script for initialising a clean Ubuntu installation and user account with a pyenv-based workflow.
#!/usr/bin/env bash
# Author: Ned Letcher
#
# This bash script is designed to configure a clean Ubuntu installation (eg new
# EC2 instance) with a somewhat opionated set of packages and tools for working
# on Python projects. In addition to installing a range of packages for dev
# work, it installs pyenv for the current user, overwriting the current .profile
# and modifying the existing .bashrc to make sure pyenv is configured correctly.
[kandinski@desire:~/data/work/hack/mal/impls/zigzug]$ pcre2-config --cflags
-I/nix/store/zl4d7qfqn5w0y06vnxcm9617yzfpbmmg-pcre2-10.36-dev/include
[kandinski@desire:~/data/work/hack/mal/impls/zigzug]$ pcre2-config --libs8
-L/nix/store/wz02m7d46hznxzv3wlgppz1syzs9wsmc-pcre2-10.36/lib -lpcre2-8
[kandinski@desire:~/data/work/hack/mal/impls/zigzug]$ zig test -lc -L/nix/store/wz02m7d46hznxzv3wlgppz1syzs9wsmc-pcre2-10.36/lib -lpcre2-8 -I/nix/store/zl4d7qfqn5w0y06vnxcm9617yzfpbmmg-pcre2-10.36-dev/include re.zig
warning: Unrecognized C flag from NIX_CFLAGS_COMPILE: -frandom-seed=ck69i4nqmv
(...)
All 11 tests passed.
@candeira
candeira / nixos.md
Created May 16, 2020 05:47 — forked from martijnvermaat/nixos.md
Installation of NixOS with encrypted root
@candeira
candeira / encryptedNixos.md
Created May 16, 2020 05:47 — forked from ladinu/encryptedNixos.md
NixOS install with encrypted /boot /root with single password unlock

Requirements

  1. Encrypt everthing including /boot and /root
  2. Enter password once
  3. Support UEFI

Installation media setup

Download NixOS minimal iso and copy to USB stick. For example on Mac OSX

$ diskutil list
$ diskutil unmountDisk /dev/disk1 # Make sure you got right device
@candeira
candeira / sc3-plugins.nix
Created October 9, 2019 04:17 — forked from gosub/sc3-plugins.nix
Nix package definition for sc3-plugins
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "sc3-plugins-3.7.0-beta";
src = fetchgit {
url = "https://github.com/supercollider/sc3-plugins";
rev = "a963ecb";
sha256="0840jwh7ljmhg34zblahqx3abk42a3y3gvgb740r558rphbp1p19";
fetchSubmodules = true;
@candeira
candeira / example-subtree-usage.md
Created August 18, 2017 07:12 — forked from kvnsmth/example-subtree-usage.md
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@candeira
candeira / spinlock-macro.h
Last active August 29, 2015 14:14
Attempting to macro-ize gallir's spinlock
// macro-ize gallir's spinlock code from:
// http://stackoverflow.com/questions/6704252/atomic-memcpy-suggestion/28286503#28286503
// third version, thanks to kragen for explains of expression/statement and do/while protective coding
#define SPINLOCK(lock) do { while ((lock) || ! __sync_bool_compare_and_swap(&(lock) , 0 , 1));} while (0)
#define SPINUNLOCK(lock) (lock) = 0;
// and the wrap-a-block version
@candeira
candeira / git-deadbranches
Created January 22, 2015 01:23
git deadbranches command deletes all local and remote branches merged into develop
#!/usr/bin/env bash
git checkout develop || (echo "Aborting..." && exit 1)
git pull || (echo "Aborting..." && exit 1)
BRANCHES=$(git branch --merged | grep -v develop | grep -v master | tr -d "\n")
for BRANCH in $BRANCHES
do