Skip to content

Instantly share code, notes, and snippets.

@southp
southp / heic-to-jpg.sh
Last active January 13, 2021 00:21
Convert HEICs in a directory to JPGs.
#!/bin/bash
# This script uses Imagemagick to do the trick.
# For platfrom-specific installation instruction, please refer to https://imagemagick.org/script/download.php
#
# Sample usage: find -iname *.heic | xargs -L1 heic-to-jpg.sh
heic=$1
if [ ! -f "$heic" ]; then
echo "Usage: $(basename $0) <target HEIC file>"
@southp
southp / prime-tests.hs
Last active August 30, 2018 00:55
Noob experiments on the prime generator - see the paper from Melissa E. O’Neill
#!/usr/bin/env stack
-- stack --resolver lts-11.14 --install-ghc runghc --package data-ordlist --package PSQueue-1.1 --package pqueue-1.4.1.1
import Text.Printf
import Data.List.Ordered ( minus )
import qualified Data.Map as Map
import qualified Data.PSQueue as PSQ
import qualified Data.PQueue.Min as PQ
import System.CPUTime
@southp
southp / group-by-date.sh
Last active May 11, 2017 03:40
Group files under the target directory into yyyy-mm date directories.
#!/bin/sh
target_dir=$1
if [ ! "$target_dir" ]; then
echo "Usage: $0 <target dir>"
exit 0
fi
if [ ! -d "$target_dir" ]; then
"use strict";
const toMs = ( diff ) => {
return diff[ 0 ] * 1000 + diff[ 1 ] / 1000;
};
const SIZE = 1000000;
let arr = [];
for ( var i = 0; i < SIZE; ++i ) {
"use strict";
const toMs = ( beg, end ) => {
const sec = end[0] - beg[0];
const ms = Math.floor( (end[1] - beg[1]) / 1000 );
return sec * 1000 + ms;
};
const SIZE = 1000000;
"use strict";
const toMs = ( beg, end ) => {
const sec = end[0] - beg[0];
const ms = Math.floor( (end[1] - beg[1]) / 1000 );
return sec * 1000 + ms;
};
const SIZE = 1000000;
// courtesy of cppreference
// http://en.cppreference.com/w/cpp/algorithm/sort
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
int main()
{
@southp
southp / gist:5660896
Last active December 17, 2015 19:29
my MBA's simple bash color
source ~/.git-prompt.sh
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PATH=/usr/local/bin:$PATH
PS1='[\[\033[01;32m\]\u \[\033[00;34m\]\h \[\033[00m\]\w$]\n\[\033[00;33m\]$(__git_ps1 "(%s)")\[\033[00m\]->$ '
@southp
southp / gist:4618051
Last active December 11, 2015 14:58
my noob gvimrc for windows
language mes en
map <F2> :TlistToggle<CR>
map <F3> :FufTag<CR>
map <C-f> :FufFile ./**/<CR>
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
@southp
southp / my noob vimrc
Last active December 11, 2015 04:28
My noob vimrc.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'bufexplorer.zip'