Skip to content

Instantly share code, notes, and snippets.

@icshih
icshih / app.py
Last active May 22, 2019 19:45
A Flask app factory template
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_admin import Admin
from flask_security import Security, SQLAlchemyUserDatastore
from config import Config
from app.views import MyModelView
db = SQLAlchemy()
admin = Admin()
@icshih
icshih / votable_to_pandas.py
Created August 3, 2018 14:43
Read VOTable file and return a Pandas DataFrame object
from astropy.io.votable import parse
import pandas as pd
def votable_to_pandas(votable_file):
votable = parse(votable_file)
table = votable.get_first_table().to_table(use_names_over_ids=True)
return table.to_pandas()
@icshih
icshih / pom.xml
Last active February 27, 2018 13:11
maven build for Java 9
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
@icshih
icshih / pyClass.ipynb
Created January 1, 2018 21:57
Python Class cheat sheet
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@icshih
icshih / visitArchive.java
Last active December 9, 2016 14:12
Visiting a zip archive
public void visitArchive(String zipFile) {
URI zipUri = URI.create("jar:file:" + zipFile);
try (FileSystem zipfs = FileSystems.newFileSystem(zipUri, new HashMap<>())) {
Files.walkFileTree(zipfs.getPath("/"), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException {
// visiting inside the archive
return FileVisitResult.CONTINUE;
}
@icshih
icshih / invoke method
Created November 20, 2014 10:07
invoke a method with parameter(s)
Class[] argTypes = new Class[1];
argTypes[0] = Object[].class;
Object[] argObj = new Object[1];
argObj[0] = objs;
Method n = null;
try {
n = g.getDeclaredMethod("processData", argTypes);
} catch (NoSuchMethodException | SecurityException e1) {
e1.printStackTrace();
}