Skip to content

Instantly share code, notes, and snippets.

View smithjessk's full-sized avatar

Jess Smith smithjessk

  • United States
View GitHub Profile
@smithjessk
smithjessk / tt.py
Created November 5, 2022 02:00
benchmarked typeguard
# %%
from torchtyping import TensorType as TT, patch_typeguard
import torch as t
from typeguard import typechecked
patch_typeguard()
# %%
def compute_times(size):
#include "RSA.h"
int main() {
RSA RSAobj;
//RSAobj.set_n();
//RSAobj.set_m();
//RSAobj.set_e();
//RSAobj.compute_d();
RSAobj.prompt();
@smithjessk
smithjessk / channel_based_aggregator.go
Last active November 2, 2016 20:48
Channel-based event aggregator
package main
import (
"fmt"
"time"
"github.com/gocraft/health"
"github.com/gorilla/websocket"
)
package main
import (
"fmt"
"math"
"math/rand"
"os"
)
func main() {
@smithjessk
smithjessk / demo.go
Created September 28, 2016 21:51
Three separate ways of errors in a `http.Handler`
package main
import (
"encoding/json"
"net/http"
)
type request struct {
ID string
}
@smithjessk
smithjessk / timing_test.go
Last active October 4, 2016 14:40
Times error handling via panics vs. if statements
package bench
import (
"errors"
"os"
"testing"
)
func TestMain(m *testing.M) {
code := m.Run()
@smithjessk
smithjessk / commit
Last active January 11, 2018 23:59
Copy the hash of the Git commit you're on
#!/bin/bash
git show -q | head -n 1 | sed 's/commit //' | tr -d '\n' | xclip -i -selection clipboard
@smithjessk
smithjessk / problem.scala
Last active August 1, 2016 18:35
Demonstrates a problem with by-name parameter extraction
// Inspired by http://stackoverflow.com/questions/29757584/handling-by-name-parameters-in-scala-macro
import scala.reflect.runtime.universe._
class X { def x(i: => Int, second: String, other: Int*) = i * 2 }
val typeSignature = typeOf[X].member(TermName("x")).typeSignature
val paramTypes = typeSignature match {
case MethodType(params, _) => params map { _.typeSignature }
}
@smithjessk
smithjessk / die.js
Created April 12, 2016 22:50
Remove those horrible, incipid flames logos from Politifact
$('img[alt="Pants on Fire!"]').remove();
#!/usr/bin/python3
import sys
lines = sys.stdin.readlines()
for line in lines:
chars = list(line)
output = ""
for char in chars:
output += char