Skip to content

Instantly share code, notes, and snippets.

View aminnj's full-sized avatar

Nick Amin aminnj

  • Austin, TX
View GitHub Profile
@aminnj
aminnj / dump_xgb.py
Created April 19, 2017 19:56
XGB model to C++ function
########################################
## # Train BDT and output model .json ##
########################################
import numpy as np
from sklearn.model_selection import train_test_split
import sys
import os
import xgboost as xgb
### Define test and train matrices somehow
@aminnj
aminnj / make_hv_summary.py
Last active October 31, 2017 13:05
Make CSCDOC HV summary table
import os
import sys
import commands
import datetime
import time
"""
1. Visit this exact URL in Google Chrome
https://cmswbm.cern.ch/cmsdb/servlet/ConditionBrowser?DISPLAY=1&SUBMIT=1D&OPTION=vs_time&STEP=3&BEGIN=2017.10.29_09:50:16&END=2017.10.31_09:50:16&PRESCALER=1&cms_omds_lb.CMS_CSC_PVSS_COND.CSC_HV.CURRENT..M13_C03..10=1&cms_omds_lb.CMS_CSC_PVSS_COND.CSC_HV.CURRENT..M13_C03..11=1&
@aminnj
aminnj / .vimrc
Created January 21, 2018 23:26
.vimrc
let g:pathogen_disabled = [] " disable certain pathogen plugins ... useful to debug
" load plugins before screwing with settings
" https://github.com/tpope/vim-commentary
" https://github.com/tpope/vim-surround
" https://github.com/tpope/vim-fugitive
" https://github.com/scrooloose/nerdtree
" https://github.com/haya14busa/incsearch.vim
" https://github.com/haya14busa/incsearch-fuzzy.vim # z/ to fuzzy search
@aminnj
aminnj / download_video.py
Last active October 18, 2023 13:52
Download reddit-hosted videos/audio
import requests
import os
# change this url to the post's url
post_url = "https://www.reddit.com/r/holdmycatnip/comments/7vyada/hmc_so_i_can_drink_this_air_real_quick/"
# use UA headers to prevent 429 error
headers = {
'User-Agent': 'My User Agent 1.0',
'From': '[email protected]'
@aminnj
aminnj / draw_model.py
Created February 20, 2018 00:00
Less verbose keras network architecture drawing
import os
import pickle
import pydot
import keras
from keras.models import load_model
"""
brew install graphviz
pip install pydot
@aminnj
aminnj / install_vim.md
Created July 9, 2018 01:50
installing vim8.1 on slc7 computers

Execute the commands chunk by chunk because I haven't tested this as a whole

# setup environment
cd /cvmfs/cms.cern.ch/slc7_amd64_gcc630/cms/cmssw/CMSSW_10_2_0_pre6/ ; cmsenv ; cd -

# make containment folder somewhere and get vi
mkdir vim8
cd vim8
git clone https://github.com/vim/vim
@aminnj
aminnj / bookmarklet.js
Last active July 21, 2018 07:48
CSC run registry table bookmarklet
/*
Copy this content as a bookmarklet.
Visit https://cmswbmoffshift.web.cern.ch/cmswbmoffshift/api/query and make sure you're authenticated (should say "Query ID missing?")
Execute the bookmark.
???
Profit.
Note: will need to search for and update the following strings below (whenever conditions change): "PromptReco-v3", "Run2018", "319750"
The queries will return at most 1k rows (usually 4k runs or so) so make sure the run number threshold isn't too small!
Well, this won't be useful after 2018...
@aminnj
aminnj / after.html
Last active June 14, 2020 05:21
live searchable apache index page directory listings
<!--
Make sure the local (or global) .htaccess file has the following line
ReadmeName after.html
-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js"></script>
<style>
mark {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import time
import numba
import numpy as np
import awkward
from awkward import JaggedArray
@numba.jit(nopython=True,cache=True)
def numba_min(content,offsets):
result = np.zeros(len(offsets)-1,dtype=content.dtype)