Skip to content

Instantly share code, notes, and snippets.

@mewmew
mewmew / natural_sort.go
Created June 30, 2019 18:00 — forked from philippbayer/natural_sort.go
A perverted kind of natural sort in golang
package main
import (
"fmt"
"log"
"sort"
"strconv"
"strings"
"unicode"
)
@mewmew
mewmew / gist:039e36dc8fd7b1d924aed7c9ef764813
Created December 20, 2018 19:17 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@mewmew
mewmew / git-extract-file.markdown
Created November 2, 2018 14:45 — forked from ssp/git-extract-file.markdown
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

/*
* LD_PRELOAD shim which applies two patches necesary to get the game
* Divinity: Original Sin Enhanded Edition for Linux to work with Mesa (12+)
*
* Build with: gcc -s -O2 -shared -fPIC -o divos-hack.{so,c} -ldl
*/
/* for RTLD_NEXT */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@mewmew
mewmew / lldb-basics.md
Created April 22, 2018 19:12 — forked from youfoundron/lldb-basics.md
lldb basics

#LLDB Basics A basic overview of lldb for personal reference.
Official documentation can be found here here.

##Command Structure General syntax

<noun> <verb> [-options [option-value]] [argument [argument...]]
@mewmew
mewmew / web-servers.md
Created February 15, 2018 13:06 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mewmew
mewmew / flavor.rb
Created November 15, 2016 09:31 — forked from ttscoff/flavor.rb
Quick wrapper to convert Markdown to HTML via Github API
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html
@mewmew
mewmew / arch-linux-install.sh
Last active May 9, 2018 15:57 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap
@mewmew
mewmew / goclean.sh
Last active April 22, 2021 22:32 — forked from h12w/goclean.sh
#!/bin/bash
# The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. goimports (http://godoc.org/golang.org/x/tools/cmd/goimports)
# 3. golint (https://github.com/golang/lint)
# 4. go vet (http://golang.org/cmd/vet)
# 5. race detector (http://blog.golang.org/race-detector)
# 6. test coverage (http://blog.golang.org/cover)