Skip to content

Instantly share code, notes, and snippets.

Hao Wu swuecho

Block or report user

Report or block swuecho

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View python_trans_of_julia_dual.py
# modified from the python code in
# https://pizzaseminar.speicherleck.de/automatic-differentiation/notes.pdf
class Dual(object):
def __init__(self, x, a=0):
self.x = x
self.a = a
def __add__(self, other):
@swuecho
swuecho / Virtual Box Host Only Static IP.md
Created May 31, 2018 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP
View Virtual Box Host Only Static IP.md

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary

View test.yaml
dashboard "Food":
- h1 text: Food
- h2 text: By caloric content
- 3 columns:
- rows:
- h3 text: Bananas
- pie chart: {
"columns": [
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]
]
View dash_test
dashboard "Food":
- h1 text: Food
- h2 text: By caloric content
- 3 columns:
- rows:
- h3 text: Bananas
- pie chart: {
"columns": [
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]
]
@swuecho
swuecho / playground.rs
Created Dec 14, 2017 — forked from anonymous/playground.rs
Rust code shared from the playground
View playground.rs
use std::str::FromStr;
fn main () {
let mut input = "15 Bear".split(' ');
// Need to pull the number and parse it.
let number = input.next()
// Process Option<&'static str> to Option<int>
.and_then(|x| i32::from_str(x).ok() )
.expect("Was not provided a valid number.");
// The next token is our animal.
@swuecho
swuecho / playground.rs
Created Dec 14, 2017 — forked from anonymous/playground.rs
Rust code shared from the playground
View playground.rs
fn main () {
let number: f64 = 20.;
// Perform a pipeline of options.
let result = Some(number)
.map(inverse) // Described below.
.map(double)
.map(inverse)
.and_then(log) // Described below.
.map(square)
.and_then(sqrt);
View ghc_precedent.hs
Prelude> (fmap . const) 1 [1..5]
[1,1,1,1,1]
Prelude> fmap . const 1 [1..5]
<interactive>:29:1: error:
Non type-variable argument in the constraint: Num (a1 -> a -> b)
(Use FlexibleContexts to permit this)
When checking the inferred type
it :: forall b a (f :: * -> *) a1.
(Num (a1 -> a -> b), Functor f) =>
View pet-snippet.toml
[[snippets]]
description = "list all files "
command = "ls -lah"
View gist:c0e9394b183edf120362390b6f4b808f

% Let's build a binary tree!

Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:

  1. must have a value
  2. may or may not have left and/or right children

So we can describe a single node like this:

View test_custom_analyzer.pl
#!/usr/local/bin/perl
package MyAnalyzer {
use v5.10;
use base qw( Lucy::Analysis::Analyzer );
sub new {
my $self = shift->SUPER::new;
return $self;
}
You can’t perform that action at this time.