Skip to content

Instantly share code, notes, and snippets.

View danjenson's full-sized avatar

Daniel Jenson danjenson

  • San Francisco, CA
View GitHub Profile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 18-854B scribe notes style file
%
% This file should be called scribe.sty
%
% Your main LaTeX file should look like this:
%
% \documentclass[12pt]{article}
% \usepackage{scribe}
%
@danjenson
danjenson / gnn.py
Created March 11, 2023 19:04
basic GNN stack
import torch
import torch_scatter
import torch.nn as nn
import torch.nn.functional as F
import torch_geometric.nn as pyg_nn
import torch_geometric.utils as pyg_utils
from torch import Tensor
from typing import Union, Tuple, Optional
@danjenson
danjenson / git_funcs.sh
Created October 19, 2022 02:08
A collection of simple git functions
#!/bin/bash
# source this file from your ~/.bashrc, i.e. `source git_funcs.sh`
# run this before making changes, otherwise you'll need to deal with merge conflicts
# usage: gitu
gitu () { git pull --rebase; }
# add it all, push it all, fuck the police
# usage: gitx
gitx () {
configuration {
/* modi: "window,run,ssh";*/
font: "FiraCode Nerd Font 30";
/* location: 0;*/
/* yoffset: 0;*/
/* xoffset: 0;*/
/* fixed-num-lines: true;*/
/* show-icons: false;*/
/* terminal: "rofi-sensible-terminal";*/
/* ssh-client: "ssh";*/
@danjenson
danjenson / user.rs
Last active September 11, 2020 19:28
use crate::db::Conn;
use crate::schema::users;
use chrono::{DateTime, Utc};
use diesel::{
associations::{HasTable, Identifiable},
delete, insert_into,
result::QueryResult,
ExpressionMethods, QueryDsl, RunQueryDsl,
};
use serde::{Deserialize, Serialize};
// inside users.rs
use crate::db::{traits::Model as DbModel, Conn};
use crate::schema::users;
use chrono::{DateTime, Utc};
use diesel::{
associations::{HasTable, Identifiable},
delete, insert_into,
result::QueryResult,
ExpressionMethods, QueryDsl, RunQueryDsl,
};
fn minimize<F>(func: F)
where
F: for<'r> Fn(f64, &'r mut f64) -> f64
{
let mmtype: rgsl::MinimizerType<f64> = rgsl::MinimizerType::brent();
let mut mm: rgsl::Minimizer<f64> = rgsl::Minimizer::new(&mmtype).unwrap();
let lambda = 0.5;
mm.set(func, &mut lambda, 0.5, 0.0, 1.0);
match rgsl::minimizer::test_interval(0.0, 1.0, 1e-6, 0.0) {
¦ rgsl::Value::Success => p!("Lambda: {}", mm.x_minimum()),
ruby -e "('A'..'Z').each { |x| ('A'..x).each { |y| print y == 'E' ? 'X' : y }; puts }"