Skip to content

Instantly share code, notes, and snippets.

View paulphys's full-sized avatar

paul paulphys

View GitHub Profile
@paulphys
paulphys / 404.tsx
Created March 23, 2021 00:16
Next.js Typescript 404 Redirect
import { useEffect } from "react"
import { useRouter } from "next/router"
export default function Custom404() {
const router = useRouter()
useEffect(() => {
router.replace("/")
})
return null
}
@paulphys
paulphys / default
Last active November 19, 2020 15:57
libstdc++11 support for conan compiler (GCC >= 5 ABI)
# ~/.conan/profiles/default
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.version=7.5
@paulphys
paulphys / robots.txt.tsx
Created September 6, 2020 18:55
robots.txt for typescript react
// directory: pages/robots.txt.tsx
import React from 'react';
const getRobots = () => `User-agent: *
Disallow: /
`;
class Sitemap extends React.Component {
public static async getInitialProps({res}:{ res:any }) {
@paulphys
paulphys / save_and_load.py
Last active December 11, 2019 00:15
Code Snippets for saving and loading different machine learning models
#Keras Models
#---Save---#
json_file = model.to_json()
with open(json_file_path, "w") as file:
file.write(json_file)
model.save_weights(h5_file)
#---Load---#
from keras.models import model_from_json
@paulphys
paulphys / remove_spaces.py
Last active November 5, 2019 20:30
removing spaces from dataframe columns
df.columns = df.columns.str.strip().str.lower().str.replace(' ', '_').str.replace('(', '').str.replace(')', '')
@paulphys
paulphys / tess.py
Last active July 25, 2020 14:30
pipeline for time series analysis on TESS light curves
import os
from astropy.timeseries import TimeSeries
from astropy.io import fits
class Lightcurve:
def __init__(self,path,telescope,instrument,date_obs_start,date_obs_end,creator,object,tessid,sector,camera,ccd,radesys,ra_obj,dec_obj,equinox,
pxtable,tessmag,radius,ticver,crmitten,crblksz,crspoc,checksum,time,timecorr,cadenceno,sap_flux,sap_flux_err,sap_bkg,sap_bkg_err,
pdcsap_flux,pdcsap_flux_err):
self.path = path
self.telescope = telescope
@paulphys
paulphys / frames_to_video.py
Last active October 19, 2019 20:18
convert frames to video with OpenCV
import cv2
import os
from os.path import isfile,join
input = '/' #folder of frames
output = 'framestovideo.mp4' #output path
fps = 25 #default 25
frame_array = []
frames = [f for f in os.listdir(input) if isfile(join(input, f))]
@paulphys
paulphys / googlecolab_drive_mount.py
Created October 12, 2019 12:34
Accessing google drive files in Google Colab by mounting drive
from google.colab import drive
drive.mount('/content/drive')
root_path = 'drive/My Drive/your_project_folder/' #your project folder