Skip to content

Instantly share code, notes, and snippets.

View Tehsurfer's full-sized avatar

Jesse Khorasanee Tehsurfer

View GitHub Profile
@Tehsurfer
Tehsurfer / arrow-nav.js
Last active June 10, 2019 23:35
Surf2surf.com video navigator
video = document.getElementsByTagName('video')[1]
window.addEventListener('keyup', function(e){
if (e.which == 37){
video.currentTime -= 5
} if (e.which == 39){
video.currentTime += 5
}
});
@Tehsurfer
Tehsurfer / remap_electrodes.py
Created June 27, 2019 23:43
Used for mapping electrodes from 'book like labelling' to the true positions
node_remap_array = [8, 16, 24, 32, 41, 33, 57, 49,
7, 15, 23, 31, 42, 34, 58, 50,
6, 14, 22, 30, 43, 35, 59, 51,
5, 13, 21, 29, 44, 36, 60, 52,
4, 12, 20, 28, 45, 37, 61, 53,
3, 11, 19, 27, 46, 38, 62, 54,
2, 10, 18, 26, 47, 39, 63, 55,
1, 9, 17, 25, 48, 40, 64, 56]
node_remap_dict = {}
@Tehsurfer
Tehsurfer / json_storage.py
Last active August 16, 2019 04:14
Python functions to create, update and get jsonstorage.net files
import requests
# Update or create storage bin
def put_json_storage(to_publish, storage_name):
headers = {'Content-Type': "application/json; charset=utf-8",'dataType': "json"}
data = json.dumps({'data': to_publish})
url = f'https://jsonstorage.net/api/items/{storage_name}'
resp = requests.put(url, headers=headers, data=data)
if resp.status_code == 200 or 201:
print(f'Data successfull uploaded: {resp.json()})')
@Tehsurfer
Tehsurfer / bf_download.py
Created September 2, 2019 04:37
Downloads a blackfynn collection to folder
import requests
from blackfynn import Blackfynn
from config import API_SECRET, API_TOKEN
import os
bf = Blackfynn(api_token=API_SECRET,api_secret=API_TOKEN)
collection = 'N:collection:0eed07e7-d147-4a2c-9411-1ea8f9ceffa5'
folder = 'downloads/'
file_type = '.abf'
import plotly.graph_objects as go
import plotly.figure_factory as ff
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import numpy as np
from scipy.spatial.distance import pdist, squareform
import pandas as pd
@Tehsurfer
Tehsurfer / tabtouch_scrape_example.js
Last active January 6, 2020 01:41
tab-touch-table-scrape
// How to use this example:
// 1. Navigate to a race's odds page. This can be found by navigating to:
// https://www.tabtouch.com.au/racing/<today's date>/<meeting abbreviation>/1
// 2. Paste the code below into the chrome console and run
// Results: First horses name and odds should be printed to console
parent = document.querySelector("tr[data-starter='1']")
@Tehsurfer
Tehsurfer / tabtouch_template.py
Created January 6, 2020 01:33
This document is to define the inputs and formatting outputs of the soon to be developed tabtouch scraper
# This document is to define the inputs and formatting outputs of the soon to be developed tabtouch scraper
# Inputs:
# date: string in form yyyy-mm-dd e.g. '2019-12-31'
# event: sting of even name e.g. 'Albury'
# race: int of race number e.g. 1
# Outputs:
# odds: Either a python dictionary, json file, or json formatted string as defined below
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("plotly.js")):"function"==typeof define&&define.amd?define("vue-plotly",["plotly.js"],n):"object"==typeof exports?exports["vue-plotly"]=n(require("plotly.js")):t["vue-plotly"]=n(t["plotly.js"])}("undefined"!=typeof self?self:this,function(t){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=23)}([function(t,n){function e(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}t.exports=e},function(t,n,e){var r=e(14),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this"
@Tehsurfer
Tehsurfer / scicrunch_queries.md
Last active November 18, 2020 22:45
Scicrunch queries for competency testing

Scicrunch comptenency queries

This document is a list of scicrunch queries currently and planned for use in ABI web apps for sparc.science All queries are made from a flask proxy server which is called from the vue front end

Queries currently used

The below snippets are pulled fom @tehsurfer/sparc-api used for the sidebar

Facets

# Type map is used to map scicrunch paths to given facet
@Tehsurfer
Tehsurfer / discover-simulation-search.py
Last active March 1, 2021 01:35
Loop through all discover datasets finding keywords. # we then search across these keywords for terms that are stimulation: 'stimulation 'and
# discover-simulation-search.py: Loop through all discover datasets finding keywords.
# we then search across these keywords for terms that are stimulation: 'stimulation 'and
import requests
keywords = []
for i in range(1,106):
r = requests.get(f'https://api.blackfynn.io/discover/datasets/{i}/versions/1/metadata')
if r.status_code is 200:
keywords.append(r.json()['keywords'])