Skip to content

Instantly share code, notes, and snippets.

@grapeot
grapeot / auto_focus.py
Created February 28, 2024 23:04
A reference implementation of auto-focusing by local entropy. https://yage.ai/auto-focus.html
"""
A class supporting the auto-focusing of a telescope.
"""
from astropy.io import fits
from astropy.stats import sigma_clipped_stats
from photutils.detection import DAOStarFinder
from glob import glob
from tqdm import tqdm
from typing import List, Dict, Any
from time import time
@grapeot
grapeot / track.py
Last active November 1, 2022 07:34
ZWO AM5自动跟踪红色滑块
import zwoasi
import cv2
import numpy as np
from simple_pid import PID
from alpaca import Telescope
def initializeCamera():
zwoasi.init('./ASICamera2.dll')
camera = zwoasi.Camera(0)
controls = camera.get_controls()
@grapeot
grapeot / extractFeatures.py
Created April 24, 2017 03:14
Use Caffe2 to extract features
# Initial imports
import os
import sys
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
from caffe2.proto import caffe2_pb2
import numpy as np
import skimage.io
import skimage.transform
set -g default-terminal "screen-256color"
set -g status-right '#[fg=black] #(hostname), %H:%M, #(uptime | egrep -o "average.*"|perl -pe "s|average: ||")'
setw -g automatic-rename
# mouse mode
set -g mode-mouse on
setw -g mouse-select-window on
setw -g mouse-select-pane on
setw -g mode-keys vi
@grapeot
grapeot / .zshrc
Last active August 29, 2015 13:55
my .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@grapeot
grapeot / install_numba.sh
Created November 19, 2013 23:37
install numba in Debian 7
sudo apt-get install llvm cython python-pip python-llvm
git clone https://github.com/numba/numba.git # Not sure whether this is necessary
cd numba
sudo pip install -r requirements.txt
sudo pip install numba
@grapeot
grapeot / gitemail.php
Created September 24, 2013 22:22
A php script to send auto email notifications when a github repo is pushed. More details available at http://grapeot.me/automatic-email-notification-on-github-pushes.html.
<?
$r = 'This is an automatically generated message notifying you that someone pushed new commits to the github repo <project>.' . " Don't forget to do git pull before your editing.\r\n\r\nEdit summary: \r\n";
$payload = $_REQUEST['payload'];
preg_match_all('@"name":"([\w ]*?)","email@', $payload, $matches);
$authors = $matches[1];
preg_match_all('@"message":"([^"]*)"@', $payload, $matches);
$messages = $matches[1];
preg_match_all('@"url":"([^"]*)"@', $payload, $matches);
$links= $matches[1];
for ($i = 0; $i < count($messages) - 1; ++$i)
@grapeot
grapeot / register.m
Last active December 23, 2015 07:18
MATLAB code to rectify the RGB and depth photos directly exported from Microsoft Kinect SDK. We assume the file `imgfn` stores the binary data directly exported from `ColorImageFrame.CopyPixelDataTo()`, `dfn` stores the binary data exported from `FusionFloatImageFrame.CopyPixelDataTo()`, and `idxfn` stores the binary data exported from the `Colo…
function newImg = register(imgfn, dfn, idxfn)
% rectify the color image according to the depth and the alignment
% information from the data collection program
% Consult http://grapeot.me/some-technical-details-about-kinectfusion.html for more details.
%% read in the data
fp = fopen(imgfn, 'r');
imgRaw = fread(fp, 'char');
imgRaw = reshape(imgRaw, 4, 640, 480);
for i = 1: 3
@grapeot
grapeot / xkcd.sh
Created May 3, 2013 04:12
Mount it on crontab, and it will send you daily xkcd pick.
num=$(curl -s xkcd.com | grep -oh -m 1 'v" href="/[0-9]*' | sed 's/v" href="\/'//)
n=$[ $RANDOM % $num ]
curl -s xkcd.com/$n/ | grep '<img.*comics' | mail -a 'Content-Type: text/html' -s 'xkcd daily pick' <email>
#include <amp.h>
#include <iostream>
#include <ctime>
#include <cstdlib>
#define TS 16
using namespace std;
using namespace concurrency;
int main()