Skip to content

Instantly share code, notes, and snippets.

View piki's full-sized avatar
🔨
Computering

Patrick Reynolds piki

🔨
Computering
View GitHub Profile
@piki
piki / push-big-repo
Last active March 4, 2024 19:57
Script to push (mirror) a large repo to GitHub
#!/bin/bash -ex
#
# Push the current repository to GitHub, in small enough chunks that it
# won't exceed the pack-size limit
# Commit to start with, counting from the oldest. If the process fails,
# you can change this variable to restart from where it failed.
START_COMMIT=1000
# Number of commits to push at a time, counting from the oldest. If a
@piki
piki / graph.rb
Last active December 15, 2021 15:09 — forked from jithinabraham/graph.rb
Dijkstra's algorithm implemented in ruby
#ruby 2.3.1 recomended
require 'set'
class Graph
attr_reader :graph, :nodes, :previous, :distance #getter methods
INFINITY = 1 << 64
def initialize
@graph = {} # the graph // {node => { edge1 => weight, edge2 => weight}, node2 => ...
@nodes = Set.new
@piki
piki / mmap.c
Created May 7, 2013 15:53
some fun with mmap and madvise
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#define CHECK(thing) if (!(thing)) { perror(#thing); exit(1); }
#define MAX_PAGE_IN 104857600