Skip to content

Instantly share code, notes, and snippets.

David James xpe

  • Berkeley, CA
Block or report user

Report or block xpe

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
@xpe
xpe / policy_gradient_loss.py
Last active Dec 23, 2018
Policy Gradient Loss function for PyTorch
View policy_gradient_loss.py
import torch
import torch.nn as nn
import torch.optim as optim
from torch._jit_internal import weak_module, weak_script_method
@weak_module
class PolicyGradientLoss(nn.Module):
"""
Multiplies an unreduced CrossEntropyLoss by a `q` vector.
"""
View why-wired-gigabit.md

Various arguments for wiring your home with Cat 6 (gigabit) ethernet or better.

Bottom-line advantages of Cat 6 over 802.11ac WiFi:

  • Better capacity. While 802.11ac, under optimal conditions, can approach 500 Mbps, having a wired connection that guarantees 1000 Mbps can be useful.
  • Better reliability.
  • Better security.
  • Better latency.

All of this said, it isn't either-or -- you can use your wired connections for connecting computers to NAS or when you need maximum speed for uploading.

@xpe
xpe / rust_wrapper_type_pros_and_cons.md
Last active Jul 11, 2018
Pros and Cons of Wrapper Types in Rust
View rust_wrapper_type_pros_and_cons.md

Pros and Cons of Wrapper Types in Rust

I've written a mathematically-oriented and computatioally-intensive application in Rust. While the mathematical theory is not necessarily difficult, keeping the various quantities clear required some care.

For this reason, I'm refactoring it to clear it up. I've created some custom structs to wrap various mathematical types.

For example, I created a type to write PDFs (probability density functions)

@xpe
xpe / default-terminal-in-ubuntu-gnome.md
Last active Mar 19, 2018
Changing the default terminal in Gnome (Ubuntu 17.10)
View default-terminal-in-ubuntu-gnome.md

I'm running Ubuntu 17.10.

After I installed Terminator, it became the default terminal in Gnome.

I would like to switch back to the default terminal.

First, I checked:

gsettings get org.gnome.desktop.default-applications.terminal exec
@xpe
xpe / nvidia-persistenced-service-permission-error.md
Created Mar 19, 2018
NVIDIA persistenced permission error
View nvidia-persistenced-service-permission-error.md

I noticed this in my syslog:

Mar 19 08:23:23 ralph systemd[1]: Configuration file /lib/systemd/system/nvidia-persistenced.service is marked executable. Please remove executable permission bits. Proceeding anyway.

I corrected the permissions with:

sudo chmod -x /lib/systemd/system/nvidia-persistenced.service
View pair_set.rs
pub struct PairSet<T> {
a: T,
b: T,
}
impl<T> PairSet<T> where T: Eq {
/// If the values are different, creates a `PairSet` with them.
pub fn new(x: T, y: T) -> Option<PairSet<T>> {
if x == y {
None
View keybase.md

Keybase proof

I hereby claim:

  • I am xpe on github.
  • I am xpe (https://keybase.io/xpe) on keybase.
  • I have a public key whose fingerprint is 20A0 61E7 8CA2 CB1C F61E 1E6D 476A 4D08 42F3 F12A

To claim this, I am signing this object:

@xpe
xpe / artifactory-project.clj
Created Mar 18, 2015
Example Artifactory project.clj for Leiningen 2.5
View artifactory-project.clj
;; To deploy to a hosted Artifactory server:
(defproject project-name "0.1.0-SNAPSHOT"
;; ...
:deploy-repositories
[["releases"
{:url "http://org-name.artifactoryonline.com/org-name/libs-releases-local"
:username :env/artifactory_user
:password :env/artifactory_pass}]
["snapshots"
{:url "http://org-name.artifactoryonline.com/org-name/libs-snapshots-local/"
View grime-dice.clj
(ns grime-dice
(:require
[clojure.pprint :refer [print-table]]))
(def dice
{:red [4 4 4 4 4 9]
:yellow [3 3 3 3 8 8]
:blue [2 2 2 7 7 7]
:magenta [1 1 6 6 6 6]
:olive [0 5 5 5 5 5]})
@xpe
xpe / iterate-until-stable-alternatives.clj
Last active Aug 29, 2015
Clojure: iterate-until-stable
View iterate-until-stable-alternatives.clj
;; gfredericks on IRC
(defn repeat-until-stable
[f x]
(->> (iterate f x)
(partition 2 1)
(filter (fn [[x1 x2]] (= x1 x2)))
ffirst))
;; amalloy on IRC
(defn repeat-until-stable
You can’t perform that action at this time.