Skip to content

Instantly share code, notes, and snippets.

View shenwei356's full-sized avatar

Wei Shen shenwei356

View GitHub Profile
@pmenzel
pmenzel / rotate_assembly.pl
Created June 18, 2022 14:44
Perl script for rotating a fasta sequence to start a specified gene search by BLAST
#!/usr/bin/env perl
#
# rotates and (if necessary reverse complements) an assembly of a circular genome
# so that it starts with the sequence having the best blast hit to a gene database,
# e.g. dnaA
#
# depends on blastn being installed
#
# Example usage:
# rotate_assembly.pl assembly.fasta dnaA.fa > rotated_assembly.fa
@clausecker
clausecker / mem.s
Created August 4, 2020 18:18
Vectorised positional popcount for Go
#include "textflag.h"
// func PospopcntMem(counts *[8]int32, buf []byte)
TEXT ·PospopcntMem(SB),NOSPLIT,$0-32
MOVQ counts+0(FP), DI
MOVQ buf_base+8(FP), SI // SI = &buf[0]
MOVQ buf_len+16(FP), CX // CX = len(buf)
SUBQ $32, CX // pre-subtract 32 bit from CX
JL scalar
@clausecker
clausecker / harness.c
Last active August 4, 2020 16:00
8 bit positional popcount with AVX2 without too much code
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
extern void pospopcnt_reg(int accum[8], const char *buf, size_t len);
extern void pospopcnt_mem(int accum[8], const char *buf, size_t len);
extern void
@kbychkov
kbychkov / gh_pages.sh
Last active November 18, 2023 15:30
Working with gh-pages as an orphan branch
# Create `gh-pages` branch from scratch
cd <dir>
git init
git remote add origin <url>
git checkout --orphan gh-pages
git add .
git commit -m "build 1.0.0"
git push origin gh-pages
@shenwei356
shenwei356 / add-timestamp-for-media-file.sh
Last active September 27, 2023 02:59
Adding create time to image/video files
#!/bin/sh
while read file; do
if [[ $string =~ .*=.* ]]; then
continue
fi
t=$(exiftool "$file" \
| grep "^Create Date" | head -n 1 \
| sed -r "s/\s+/ /g" | cut -d " " -f 4 \
@bsmith89
bsmith89 / Makefile
Created February 5, 2016 19:21
Minorly redacted Makefile for a project using mothur to analyze 16S data.
# ====================
# Project Makefile
# ====================
# User Configuration {{{1
# ====================
# Major targets {{{2
.PHONY: figs res
figs:
# [Partially redacted]
@evantoli
evantoli / GitConfigHttpProxy.md
Last active April 17, 2024 15:37
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@petervmeijgaard
petervmeijgaard / todo-vue-example.html
Last active September 13, 2017 05:24
Todo Vue.js Example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Todo Vue.js Example</title>
<link rel="stylesheet"
type="text/css"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>
<style type="text/css">
@mcastilho
mcastilho / gist:e051898d129b44e2f502
Last active June 23, 2023 18:33
Cheap MapReduce in Go
package main
import (
"bufio"
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
<p>
My programming language of preference is python for the simple reason that I feel I write better code faster with it then I do with other languages. However also has a lot of nice tricks and idioms to do things well. And partly as a reminder to myself to use them, and partly because I thought this might be of general interest I have put together this collection of some of my favourite idioms. I am also putting this on <a href="https://gist.github.com/codefisher/9d7993ddbf404c505128">gist.github.com</a> so that anyone that wants to contribute there own things can, and I will try and keep this post up to date.
</p>
<h2>enumerate</h2>
<p>
A fairly common thing to do is loop over a list while also keeping track of what index we are up to. Now we could use a <code>count</code> variable, but python gives us a nicer syntax for this with the <code>enumerate()</code> function.
<script src="https://gist.github.com/codefisher/9d7993ddbf404c505128.js?file=enumerate.py"></script>