Skip to content

Instantly share code, notes, and snippets.

View zjhmale's full-sized avatar
🏠
Working from home

xxx zjhmale

🏠
Working from home
View GitHub Profile
@zjhmale
zjhmale / xxfx.zsh-theme
Created December 13, 2018 03:36
customized xxf zsh theme
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@zjhmale
zjhmale / xxfx.zsh-theme
Created December 13, 2018 03:36
customized xxf zsh theme with
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@zjhmale
zjhmale / xxfx.zsh-theme
Created December 13, 2018 03:36
customized xxf zsh theme with
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@zjhmale
zjhmale / derive-json.hpp
Last active November 2, 2017 10:50
auto generate serializers and deserializers
//https://stackoverflow.com/questions/24309309/how-to-use-boost-preprocessor-to-generate-accessors
#include <boost/preprocessor.hpp>
#define CREATE_MY_MACRO_PLACEHOLDER_FILLER_0(X, Y, Z) \
((X, Y, Z)) CREATE_MY_MACRO_PLACEHOLDER_FILLER_1
#define CREATE_MY_MACRO_PLACEHOLDER_FILLER_1(X, Y, Z) \
((X, Y, Z)) CREATE_MY_MACRO_PLACEHOLDER_FILLER_0
#define CREATE_MY_MACRO_PLACEHOLDER_FILLER_0_END
#define CREATE_MY_MACRO_PLACEHOLDER_FILLER_1_END
@zjhmale
zjhmale / main.cpp
Created October 21, 2017 17:01 — forked from brotchie/main.cpp
Minimal C++ implementation of Functor, Monad and Maybe using c++0x variadic templates and lambda expressions.
/*
* Minimal C++ implementation of Functor, Monad and Maybe.
*
* Requires c++0x variadic templates and lambda expressions:
*
* g++ -std=c++0x main.cpp -o main
*
* fmap, monadic bind and return implementations for std::vector
* and Maybe.
*
@zjhmale
zjhmale / spacemacs_hint.md
Created October 2, 2017 08:08 — forked from ivar/spacemacs global search and replace.md
spacemacs - global search and replace

There's a couple of ways, one way is

  • Get search results
    • Do SPC / and type in your search string
    • or SPC x S and search string - where x is your scope indicator (p for project, d for directory, etc..)
  • Once you have the occurences you want, hit C-c C-e inside the helm buffer to put all your match occurences and puts them into a special buffer called the edit buffer or something like that
  • in that buffer you can use any commands you'd normally use on a buffer
  • the C-c C-c to commit your changes.
@zjhmale
zjhmale / fm.hs
Last active April 28, 2017 09:16
Function (Reader) Monad
foo :: Int -> Int
foo a = a + 1
bar :: Int -> Int
bar a = a - 1
foobar' :: Int -> [Int]
foobar' = sequence [foo, bar]
foobar :: Int -> Int
(defn Y [f]
((fn [x] (x x))
(fn [x]
(f (fn [& args]
(apply (x x) args))))))
(def fib
(fn [f]
(fn [n]
(condp = n
* in scala
List(1,2,3).flatMap(x => Some(x))
* in swift
[1,2,3].flatMap{(n:Int) -> Int? in Optional(n)}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.Brainfuck.Parser
(parse)
where
import Control.Monad.Except
import Control.Monad.State
data ParseError = Unexpected Char