Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@scturtle
scturtle / c2a.py
Created July 5, 2019 14:47
curl to aria2
#!/usr/bin/env python
import sys
cmd = "aria2c --no-conf '{}'".format(sys.argv[2])
i = 3
while i < len(sys.argv):
arg = sys.argv[i]
i += 1
if arg == '-H':
arg = sys.argv[i]
import logging
class ColoredFormatter(logging.Formatter):
def __init__(self, fmt, datefmt=None):
logging.Formatter.__init__(self, fmt, datefmt)
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)
self.COLORS = dict(
DEBUG=GREEN, INFO=WHITE, WARNING=YELLOW, ERROR=RED, CRITICAL=MAGENTA
)
@scturtle
scturtle / index.html
Last active June 5, 2019 02:58
simple vue template with element-ui
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome to Vue</title>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.bootcss.com/element-ui/2.7.2/index.js"></script>
<script src="https://cdn.bootcss.com/element-ui/2.7.2/locale/zh-CN.min.js"></script>
<link href="https://cdn.bootcss.com/element-ui/2.7.2/theme-chalk/index.css" rel=stylesheet>
</head>
@scturtle
scturtle / spline.h
Created September 21, 2018 13:56
Cubic B-Spline interpolation of SE(3)
#pragma once
#include <sophus/se3.hpp>
// follows spline fusion paper
// modified from minimal_ceres_sophus and kontiki
// forward declaration
namespace ceres
{
@scturtle
scturtle / autodiff.cc
Last active June 1, 2022 10:36
Levenberg-Marquardt algorithm with Eigen.
#include <glog/logging.h>
#include <unsupported/Eigen/AutoDiff>
#include <unsupported/Eigen/LevenbergMarquardt>
template <typename T>
Eigen::Matrix<T, Eigen::Dynamic, 1>
func(const Eigen::Matrix<T, Eigen::Dynamic, 1> &xs,
const Eigen::Matrix<T, 3, 1> &x)
{
auto xsa = xs.array();
@scturtle
scturtle / SATurtle.cc
Last active August 9, 2018 01:44
naive SAT solver using DPLL algorithm
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
namespace SATurtle {
struct CNF {
CNF(const std::string &fn);
int vc = 0; // #var
#include <Eigen/Core>
#include <ceres/ceres.h>
#include <ceres/rotation.h>
#include <fstream>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <vector>
DEFINE_string(problem, "problem-49-7776-pre.txt", "dataset file name");
@scturtle
scturtle / fibo.cc
Created January 3, 2018 02:53
fibonacci in tail recursion template
#include <iostream>
template<int N>
struct fibo_result { int val = N; };
template<int ...Ns>
struct fibo_impl;
template<int a, int b, int I, int ...Ns>
struct fibo_impl<a, b, I, I, Ns...>
@scturtle
scturtle / ast_dump.py
Created December 16, 2017 15:59
Dump Clang AST with python bindings.
#!/usr/bin/env python3
import sys
import clang.cindex
INDENT = 4
K = clang.cindex.CursorKind
def is_std_ns(node):
return node.kind == K.NAMESPACE and node.spelling == 'std'
@scturtle
scturtle / packages.el
Last active December 4, 2017 17:17
lsp-cquery layer
;;; packages.el --- lsp-cquery layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Shen Chao <scturtle@Enigma.lan>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3