Skip to content

Instantly share code, notes, and snippets.

View boichee's full-sized avatar

Brett Levenson boichee

  • Facebook
  • San Francisco, CA
View GitHub Profile
@boichee
boichee / fix_mosh_server.sh
Last active August 1, 2019 20:15
A shell function for macOS that allows mosh-server to send/receive traffic without having to deactivate the firewall
# Mosh Server on macOS Mojave is blocked by the packet filter.
# Modifying the pf.conf for pfctl is not enough to make it work.
# The following function does, however, seem to allow the necessary
# traffic to pass through the firewall
fix_mosh_server() {  ✔  10037  13:10:10
local fw='/usr/libexec/ApplicationFirewall/socketfilterfw'
local mosh_sym="$(which mosh-server)"
local mosh_abs="$(greadlink -f $mosh_sym)"
@boichee
boichee / RotatedArrayDCSeach.js
Created September 26, 2014 02:57
Divide and Conquer Algo for Searching a Sorted, Rotated Array
// Going to create a way to search a rotated array that uses a divide and conquer approach rather than the standard binary tree method
var maxNumber = 50000// Or use something like Math.pow(2,31) to create a large binary integer; // A 32 bit integer, since bitwise only works on 32 bit ints
function splitList(arr, sections) {
// arr = the list we're searching
// num = the number we're searching for
// sections = the number of sections to break the larger list into
var a = []; // Create a new array to hold the multiple arrays
@boichee
boichee / jsfid-console-emu.css
Created September 13, 2014 10:14
Simple console emulator for JSFiddle - CSS Pane
.console {
font-family: monospace;
margin: 2px;
}
.large {
font-size: 1.5em;
}
/* Define the prompt */
.console p.help:before {
content:"";
@boichee
boichee / jsfid-console-emu.html
Created September 13, 2014 10:12
Simple console emulator for JSFiddle - HTML Pane
<div class="console large">Console Emulator:</div>
<div id="console-log" class="console">
<p class="help">Just use console.log("...") as you normally would.</p>
</div>
@boichee
boichee / jsfid-console-emu.js
Created September 13, 2014 10:10
Simple console emulator for JSFiddle
// JS Console Emulator
console = {
log: function (text) {
console.linecount = console.linecount++ || 1;
if (console.linecount === 1) $("#console-log").empty();
$("<p/>", {
html: text
}).appendTo("#console-log");
}
};