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
@matthewjberger
matthewjberger / create_neovim_qt_deb.sh
Created April 25, 2017 21:53 — forked from maorv/create_neovim_qt_deb.sh
Install neovim-qt on ubuntu
#!/bin/sh
echo "Install neovim from ppa"
sudo add-apt-repository -y ppa:neovim-ppa/unstable
sudo apt-get update
sudo apt-get install -y neovim
echo "Compile and install neovim-qt"
git clone https://github.com/maorv/neovim-qt.git
cd neovim-qt && mkdir build && cd build
@matthewjberger
matthewjberger / sample-google.c
Created April 7, 2017 03:59 — forked from davidzchen/sample-google.c
Sample C code using the Google C++ style guide
// Sample file using the Google C++ coding standard.
//
// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
//
// General rules:
// - Indents are two spaces. No tabs should be used anywhere.
// - Each line must be at most 80 characters long.
// - Comments can be // or /* but // is most commonly used.
// - File names should be lower_case.c or lower-case.c
//
@matthewjberger
matthewjberger / gh-pages with template via git
Created April 1, 2017 05:08 — forked from gingerhendrix/gh-pages with template via git
github pages installed in a project as a blank branch, and a submodule and with a remote used to pull down shared template
#Create blank branch
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
touch .gitignore
git add .gitignore
git commit -m "Initial Commit"
#Push to origin
git push origin gh-pages
@matthewjberger
matthewjberger / guake zenburn theme
Created March 19, 2017 00:14 — forked from scmanjarrez/guake zenburn theme
guake terminal theme - zenburn
#!/bin/bash
gconftool-2 -s -t string /apps/guake/style/font/palette "#3F3F3F3F3F3F:#CCCC93939393:#7F7F9F9F7F7F:#E3E3CECEABAB:#DFDFAFAF8F8F:#CCCC93939393:#8C8CD0D0D3D3:#DCDCDCDCCCCC:#3F3F3F3F3F3F:#CCCC93939393:#7F7F9F9F7F7F:#E3E3CECEABAB:#DFDFAFAF8F8F:#CCCC93939393:#8C8CD0D0D3D3:#DCDCDCDCCCCC"
gconftool-2 -s -t string /apps/guake/style/font/color "#ffffffffffff"
gconftool-2 -s -t string /apps/guake/style/background/color "#2E2E34343636"
@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;
}
@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;
}
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 / 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
@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.