Skip to content

Instantly share code, notes, and snippets.

View chriscasola's full-sized avatar
🤓

Chris Hoff chriscasola

🤓
View GitHub Profile
@chriscasola
chriscasola / type-checker.ts
Created May 11, 2021 12:37
Type-check typescript in vue files
import * as path from 'path';
import * as ts from 'typescript';
import * as vtc from 'vue-template-compiler';
function compile(fileNames: string[], options: ts.CompilerOptions): void {
const baseHost = ts.createCompilerHost(options);
const host: ts.CompilerHost = {
...baseHost,
resolveModuleNames(
moduleNames,
@chriscasola
chriscasola / pi-hole-vpn-setup.md
Last active June 13, 2020 02:36
PiVPN / Pi-Hole Setup on Raspberry Pi

Install PiVPN - https://pivpn.io/

  1. sudo -i
  2. vi /etc/wireguard/wg0.conf
  3. Add DNS = 10.6.0.1 (the wireguard IP of the Pi)
  4. Add this to forward all traffic to the internet
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
template<unsigned n> class Fib {
public:
enum {
value_type = Fib<n-1>::value_type + Fib<n-2>::value_type
};
};
template <> class Fib<1> {
public:
enum { value_type = 1 };
@chriscasola
chriscasola / undo-ff-merge
Created February 9, 2013 22:34
Undo a fast-forward merge
git reflog show master
git reset --keep master@{1}
@chriscasola
chriscasola / README.txt
Last active June 13, 2022 08:30
A python script to generate a table of contents for a GitHub Flavored markdown file. The file must contain a level one header with a title that contains "Table of Contents". The script will generate a TOC containing all level 1, 2, and 3 headers.
A python script to generate a table of contents (with links) for a GitHub Flavored markdown file.
The file must contain a level one header with a title that contains "Table of Contents".
The script will generate a TOC containing all level 1, 2, and 3 headers.
Run the script like this:
python tocgen.py inFileName outFileName
BEFORE file:
--------------------------------------------------------
This is my GitHub wiki page.
@chriscasola
chriscasola / DefectChangeset.java
Created January 23, 2013 03:27
This snippet shows how to write a custom deserializer for Gson that can handle a class with a generic type parameter. In this case, the DefectChangeset class is being deserialized, which has a field called changes of type Map<String, FieldChange<?>>. There may be better ways to do this, but it works.
public class DefectChangeset extends DefectEvent {
private Map<String, FieldChange<?>> changes;
/**
* Construct a DefectChangeset with default properties.
*/
public DefectChangeset() {
type = EventType.CHANGESET;
changes = new HashMap<String, FieldChange<?>>();