Skip to content

Instantly share code, notes, and snippets.

View paddy74's full-sized avatar

Patrick Young paddy74

View GitHub Profile
@paddy74
paddy74 / InitSubmodules.cmake
Created June 3, 2019 19:16
Using CMake, initializes any existing submodules
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git/modules")
# Update submodules as needed
OPTION(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Git submodules found - updating")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
@paddy74
paddy74 / .clang-format
Last active February 12, 2020 00:58
My personal clang-format files
---
# Default style options for all languages
BasedOnStyle: Google
ColumnLimit: 79
IndentWidth: 4
IndentWrappedFunctionNames: true
TabWidth: 4
DeriveLineEnding: false
@paddy74
paddy74 / install-nodejs.sh
Last active October 30, 2020 22:28
For setting up my Ubuntu enviornment
#!/bin/bash
# Using nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
source ~/.bashrc
nvm -v
nvm install node # latest
nvm install 12.16.3 # nvm install --lts
nvm alias default 12.16.3 # nvm alias default lts/*
@paddy74
paddy74 / format_all.sh
Created May 8, 2019 17:15
Formats a file in LETOR 4.0 format to LibSVM format
#!/bin/bash
format_mq() {
echo $1/$2
cd $1
cd $2
chmod 777 ./*
chmod 777 Fold1/*
chmod 777 Fold2/*
@paddy74
paddy74 / ngramify.cpp
Created April 17, 2019 21:35
A simple function for the collection of ngrams for a vector of strings.
/**
* MIT License
*
* Copyright (c) 2019 Patrick Cox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONN
@paddy74
paddy74 / azure_search_curl_query.sh
Last active March 29, 2019 18:05
Searching Documents from Azure Search using cUrl (with decoding & JSON Pretify)
#!/bin/sh
SERVICE_NAME='<Azure Search Service Name>'
API_VER='2017-11-11'
ADMIN_KEY='<API KEY>'
CONTENT_TYPE='application/json'
INDEX_NAME='Azure Search Service index name>'
URL="https://$SERVICE_NAME.search.windows.net/indexes/$INDEX_NAME/docs?api-version=$API_VER"
{
@paddy74
paddy74 / arxiv_search_save.py
Created March 27, 2019 22:28
Query arxiv and save the results
import os
import json
import requests
import feedparser
from bs4 import BeautifulSoup
from bs4.element import Comment
@paddy74
paddy74 / visible_webpage_text.py
Created March 26, 2019 23:05
Grab the visible text from a webpage
"""Grab the visible text from a webpage
Based on the stackoverflow post https://stackoverflow.com/questions/1936466/beautifulsoup-grab-visible-webpage-text
"""
from bs4 import BeautifulSoup
from bs4.element import Comment
import requests
def tag_visible(element):
if element.parent.name in ['style', 'script', 'head', 'title', 'meta', '[document]']:
@paddy74
paddy74 / UploadToIndex.cs
Created March 22, 2019 18:39
Azure search handle uploading to index
private static void UploadToIndex<T>(ISearchIndexClient indexClient, IndexBatch<T> batch, int count=0)
{
try
{
indexClient.Documents.Index(batch);
}
catch (IndexBatchException e)
{
// Try to index n times and give up if it still fails
if (count == 5)
@paddy74
paddy74 / simple_twitter_crawler.py
Created March 19, 2019 22:17
Collects a list of links by crawling tweets while filtering for keywords
#!usr/bin/env python3
#############################################
# Author: Patrick T Cox
# Date Created: 16 February 2017
# Date Updated: 15 November 2017
# Project: Simple Twitter Crawler
# File: simple_twitter_crawler.py
#
# Description: Collects a list of links by crawling tweets while filtering