Skip to content

Instantly share code, notes, and snippets.

View jstirnaman's full-sized avatar

Jason Stirnaman jstirnaman

View GitHub Profile
@jstirnaman
jstirnaman / params-query-sql.md
Last active March 21, 2024 17:37
InfluxDB v3 parameterized query examples using influxdb3-go
Write using the Go client.
import (
	"context"
	"fmt"
	"log"
@jstirnaman
jstirnaman / main.js
Created November 9, 2023 20:26
JavaScript influxdb3-client v0.4.0 query with Async Generator
import {InfluxDBClient} from '@influxdata/influxdb3-client'
// Run as `node main.js`
async function main() {
// Runs the query and logs the expected output for each run.
withTimer(query, 5);
// Runs the query and logs the expected output for the first run,
// but not for subsequent executions (of `node main.js`) until after some amount of time has passed.
@jstirnaman
jstirnaman / pytorch-tut.py
Created May 12, 2023 01:12
pytorch tutorial
import torch
import numpy as np
# Create a tensor from data
data = [[1, 2],[3, 4]]
x_data = torch.tensor(data)
# Create a tensor from a NumPy array
np_array = np.array(data)
x_np = torch.from_numpy(np_array)
@jstirnaman
jstirnaman / git-lines.rb
Created October 24, 2016 02:42
Report lines added and removed by an author.
## Lines of code per work week.
# Lines by Jason
# galter-website
# "added lines: 7510, removed lines: 3868, total lines: 3642\n lines per wk: 62"
# fasis-identity
# "added lines: 10851, removed lines: 3102, total lines: 7749\n lines per wk: 133"
# digital-repository
# "added lines: 521, removed lines: 253, total lines: 268\n lines per wk: 4"
# galter_dashing
# "added lines: 131, removed lines: 81, total lines: 50\n lines per wk: 0"
<!-- Article Matcher Request -->
<!-- Docs; http://ip-science.interest.thomsonreuters.com/data-integration
<!--
Throttling docs: www.wokinfo.com/kb/114032
Post to https://ws.isiknowledge.com/cps/xrpc
-->
<?xml version="1.0" encoding="UTF-8" ?>
<request xmlns="http://www.isinet.com/xrpc42" src="app.id=NU_Galter_Elements">
<fn name="LinksAMR.retrieve">
## Put this in [root]/script and make executable.
# Dependencies: Class Pubmed for searching
OUTFILE = Rails.root.join("tmp/entrez-data#{Time.now.tv_sec}")
DOI_SOURCE_FILE = ''
## DOIs
# Assumes source is a CSV of DOIs from Windows/Excel and not in UTF-8
def dois
Enumerator.new do |e|
@jstirnaman
jstirnaman / .cvimrc
Last active August 29, 2015 14:27
cVim settings
" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 70
let barposition = "bottom"
@jstirnaman
jstirnaman / entrez.rb
Created May 20, 2015 14:25
Ruby module for accessing NLM's Eutils for Entrez, specifically Medline, and returning specific details (e.g. grants) from the Medline record.
require 'bio-table'
require 'bio'
require 'rdf'
require "addressable/template"
require 'linkeddata'
require 'httparty'
require 'nokogiri'
require "csv"
require 'uri'
@jstirnaman
jstirnaman / jp2metadata
Created May 19, 2015 19:33
Print JPEG2000 metadata using jp2dump from Glymur, the Python interface to OpenJPEG
# Pipe each line of ls output to xargs. Execute command for each line in xargs.
ls kumc*1889*burton*jp2 | xargs -n1 jp2dump
@jstirnaman
jstirnaman / fibonacci.rb
Last active August 29, 2015 14:19
Fibonacci
def fibonacci(f=[0,1])
f << (f.last + f[f.size-2])
end
#n is 1-based
def get_fib(n=1)
f = fibonacci
while f.size < n
f = fibonacci(f)
end