Skip to content

Instantly share code, notes, and snippets.

View matthewjberger's full-sized avatar
🦀
Writing something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Writing something in Rust, probably
  • Hyphen
View GitHub Profile
* root topic - TAB and S-TAB to toggle folding
** child topic
child topic text
*** leaf topic:
some text blah
blah
blah
*** another leaf topic:
# test table - TAB to cycle through columns, M-e to move point to end of cell

Keybase proof

I hereby claim:

  • I am matthewjberger on github.
  • I am matthewjberger (https://keybase.io/matthewjberger) on keybase.
  • I have a public key whose fingerprint is 6314 2AE2 EB04 8B8F 56EA 69FA 5A0D 1012 B518 A821

To claim this, I am signing this object:

@matthewjberger
matthewjberger / no-box.md
Created January 3, 2017 18:35 — forked from lifthrasiir/no-box.md
Idiomatic Rust: Yes I'm really trying to write something similar

No Box<T>

tl;dr: Avoid Box<T> in general.

Actually, this rule is so important that the Rust Pointer Guide explicitly says the same. Therefore without a further ado, you should avoid Box<T> except for these three cases:

  1. When you absolutely need a trait object (Box<Trait>). But review carefully to see if it is indeed absolutely needed; you may try to generalize things too far, for example.

  2. When you have a recursive data structure. This may be mandatory when you have an inherently recursive data (e.g. scene graph), but it may also be a sign of the premature optimization. Again, review carefully to see if you need to write a separate data structure yourself, and use the collection crate if possible.

@matthewjberger
matthewjberger / purge.sh
Last active February 2, 2017 00:12 — forked from adrienbrault/purge.sh
Script to reduce VM size before packaging for vagrant (adapted for debian/ubuntu)
#!/bin/bash
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
apt -y purge ri
apt -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
apt -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
apt -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5
If you have a huge repository (in size and in history) and want to add a subfolder
to your project as a submodule you can follow this example to save time and space
using git's shallow clone and shallow checkout feature. It is a bit more complicated
in this example because I assume that you want your submodule to track a non-default
branch, called `mybranch`, instead of the `master` branch. Things could probably get
a lot simpler when using the default branch. After following the commands in these
examples you can use `git submodule update` and `git submodule update --remote` as normal.
@matthewjberger
matthewjberger / settings.json
Created February 17, 2017 05:40
Spacemacs-Like settings for vscode. Very incomplete
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Hack",
"editor.fontSize": 18,
// Specifies path to /src directory of local copy of Rust sources
"rust.rustLangSrcPath": "C:\\Users\\Matth\\Home\\rust\\src",
"vim.easymotion": true,
"vim.incsearch": true,
@matthewjberger
matthewjberger / settings.json
Last active February 17, 2017 21:19
vscode settings
{
// Use the hack font
"editor.fontFamily": "Hack",
// Font size
"editor.fontSize": 18,
// Tabs are equivalent to this many spaces
"editor.tabSize": 4,
@matthewjberger
matthewjberger / gist:5a63841c870a81fd609f772fd5c25008
Created March 10, 2017 19:39 — forked from mbains/gist:3406184
Factory pattern using C++ templates
#include <iostream>
#include <map>
using namespace std;
class BaseClass{
public:
virtual int funk() {
return 0;
}
@matthewjberger
matthewjberger / gist:2c9c234df1e42484bc624c86da27969d
Created March 10, 2017 19:40 — forked from mbains/gist:3406184
Factory pattern using C++ templates
#include <iostream>
#include <map>
using namespace std;
class BaseClass{
public:
virtual int funk() {
return 0;
}