Skip to content

Instantly share code, notes, and snippets.

View nathanharper's full-sized avatar
🤠

Nathan Harper nathanharper

🤠
View GitHub Profile
@nathanharper
nathanharper / .vimrc
Created January 3, 2025 13:25
minimal vimrc
" vim-plug setup
call plug#begin()
Plug 'altercation/vim-colors-solarized'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdcommenter'
Plug 'dkprice/vim-easygrep'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'preservim/nerdtree'
Plug 'pangloss/vim-javascript'
Plug 'plasticboy/vim-markdown'
/** @param {NS} ns **/
export async function main(ns) {
const server = ns.args[0] ?? ns.getHostname();
while(1){
await ns.hack(server);
}
}
@nathanharper
nathanharper / Raw.jsx
Last active June 18, 2018 14:24
React component to output Raw HTML without using dangerouslySetInnerHTMLOMGWhyAreYouDoingThisPleaseStop
import React from 'react';
/**
* Helper component for injecting raw html into the page.
*/
const rawFactory = type =>
class RawComponent extends React.Component {
render() {
const { children: strings, ...props } = this.props;
#!/bin/bash
git branch -u origin/$(git rev-parse --abbrev-ref HEAD)
@nathanharper
nathanharper / mock-promise.js
Last active July 5, 2018 02:54
Mock a promise object for jest tests
// Put this in your "setupEnvScriptFile" for Jest.
// usage: `jest.genMockFn().mockReturnValue(promisify('whateva'))`
promisify = function (returnValue, delay) {
delay = !!delay;
let delayCount = 0;
let recursiveMockPromise = new function () {
let self = this;
self.returnValue = returnValue;
Time.new().strftime("%Y%m%d%H%M%S")
git tag -d 12345
git push origin :refs/tags/12345
#!/usr/bin/env bash
nc -l localhost 12345
curl -H "Content-Type: application/json" -X POST -d '{"lol": "data"}' http://localhost:12345
@nathanharper
nathanharper / default-csrf.js
Last active January 22, 2018 11:56
axios default CSRF Token
let csrfToken = 'lololololol';
let axiosDefaults = require('axios/lib/defaults');
axiosDefaults.headers.common['X-CSRF-Token'] = csrfToken;
@nathanharper
nathanharper / java_switch.sh
Created January 6, 2015 14:27
Switch Java Version
/usr/libexec/java_home -v 1.8.0_25 --exec javac -version