Skip to content

Instantly share code, notes, and snippets.

🐾
Likes nekomimis. = ^ . ^ =

Alex Belanger nitrix

🐾
Likes nekomimis. = ^ . ^ =
Block or report user

Report or block nitrix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:7bd0750bc89b2ef15c9c199f05de8b56
func triangularNumberOf(n int) int {
return n * (n + 1) / 2
}
func reverseTriangularNumberOf(sum int) int {
n := (math.Sqrt(8 * float64(sum) + 1) - 1) / 2
return int(math.Ceil(n))
}
@nitrix
nitrix / gist:ff6cacbe5790605f4e61dbe9dda5e9e2
Created May 1, 2019
Bash profile useful aliases at work
View gist:ff6cacbe5790605f4e61dbe9dda5e9e2
# Docker Compose
# Runs a docker command of your choice from anywhere.
#
# Usage: dc <command>
dc() {
docker-compose --project-directory ~/Documents/Repos/workspace -f ~/Documents/Repos/workspace/docker-compose.yml $@
}
# Docker Compose Restart.
# Restart a container by name.
View gist:545a7d0c05ed5ae9049ae47ee0ac1ced
; Turn nasm into 16-bit mode
BITS 16
; Set origin address
ORG 0x7C00
; MEMORY LAYOUT
; 0x0000 - 0x0500 Interrupt Vector Table, BIOS Data Area
; 0x0500 - 0x7C00 Stack (growing down)
; 0x7C00 - 0x7E00 First stage bootloader
; 0x7E00 - 0xFFFF Free for use!
View gist:1cd58cf20d7c4778f588751864b5b863
dc() {
docker-compose --project-directory ~/Documents/Repos/ws-development -f ~/Documents/Repos/ws-development/docker-compose.yml $@
}
# Docker compose restart
dcr() {
dc kill "$1"
dc up -d "$1"
}
View SKI.hs
module SKI where
data SKI = S | K | I | A SKI SKI
deriving (Eq, Show)
reduce :: SKI -> SKI
reduce (A (A (A S x) y) z) = reduce (A (A x z) (A y z))
reduce (A (A K x) y) = reduce y
reduce (A I x) = reduce x
reduce a@(A f x) = let f' = reduce f in if f==f' then a else reduce (A f' x)
@nitrix
nitrix / keybase.md
Last active Oct 28, 2018
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am nitrix on github.
  • I am nitrix (https://keybase.io/nitrix) on keybase.
  • I have a public key whose fingerprint is 6B82 F2F3 1479 D465 AEBF F52A 0AFB A2E7 FA59 5691

To claim this, I am signing this object:

View gist:70275439c8d12fab67c951ac0d9884da
{-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances, TypeFamilies, PolyKinds, GADTs, MultiParamTypeClasses, FunctionalDependencies, RankNTypes, DataKinds #-}
import Data.Kind
import Prelude hiding (id, (.), Functor(..), Monad(..), Monoid(..))
-- 'Category k' is a category whose objects are 'Ob k a => a' and whose
-- morphisms (of kind *) are '(Ob k a, Ob k b) => k a b'
class Category (k :: o -> o -> *) where
type Ob (k :: o -> o -> *) (a :: o) :: Constraint
id :: Ob k a => k a a
(.) :: (Ob k a, Ob k b, Ob k c) => k b c -> k a b -> k a c
@nitrix
nitrix / testgp.php
Last active May 17, 2016
Test genetic programming
View testgp.php
<?php
$instructions = ['0', '1', '+', '-', '*', '/', '>', '<', '=', '|', '&', '@', '!', '#', '(', ')', '%', '_'];
$instructionsLength = count($instructions) - 1;
while (true) {
$program = '';
for ($i = 0, $c = rand(0, 10); $i < $c; $i++) {
$program .= $instructions[rand(0, $instructionsLength)];
}
View gist:2c6c5067b6d400fbe51b
nitrix@pluto ~/projects/ni/boot [develop]$ php vm.php test
Instruction SBNZ [$0=9, $1=0, $2=8, $3=-1]
Enter a character: f
Performing `$8 = $0 - $9`, the values are `-11 = 102 - 113`
Instruction SBNZ [$4=1, $5=1, $6=8, $7=0]
Performing `$8 = $1 - $1`, the values are `0 = 0 - 0`
Result is zero, branching to 0
Instruction SBNZ [$0=9, $1=0, $2=8, $3=-1]
Enter a character: g
Performing `$8 = $0 - $9`, the values are `-10 = 103 - 113`
View gist:d921de1767bf8fd933a7
.global main
.global printf
.text
main:
mov %rsp, base
jmp next
core:
next:
mov ip, %rax
add $8, ip
You can’t perform that action at this time.