Skip to content

Instantly share code, notes, and snippets.

@zcunlin
zcunlin / weasel.custom.yaml
Last active December 16, 2015 17:59 — forked from aben/Solarized_Rock.yaml
所有的颜色都来自solarized:http://ethanschoonover.com/solarized
#weasel.custom.yaml
patch:
"preset_color_schemes/Solarized_Lite":
author: "五磅兔 zcunlin@foxmail.com, based on Aben's 曬經石\solarized_Rock, original artwork by ethanschoonover‘s solarized"
back_color: 0xe3f6fd #底色
border_color: 0xd5e8ee #边框色
candidate_text_color: 0x837b65 #候选项颜色
comment_text_color: 0xd28b26 #编码提示颜色
hilited_back_color: 0xd5e8ee #编码底色
hilited_candidate_back_color: 0x98a12a #首选项高亮背景色
#![feature(test)]
extern crate rand;
extern crate test;
#[macro_use]
extern crate nom;
use nom::*;
@chalmagean
chalmagean / onSelect.elm
Last active December 22, 2016 06:21
Elm onSelect decoder
-- Assuming we have a list of items in the model (type alias Model = { items : List Item }
-- where Item is a record like { id : Int, name : String }
-- this goes in the view and generates an html dropdown
select
[ onSelect ValueSelectedMsg ]
(List.map (\item -> option [ value (toString item.id) ] [ text item.name ]) model.items)
targetSelectedIndex : Json.Decoder Int
@martinmoene
martinmoene / catch-main.cpp
Last active September 6, 2017 01:43
CATCH - Small complete multi-file example.
// This tells Catch to provide a main() - only do this in one cpp file:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
@mikehearn
mikehearn / threadbox.kt
Created August 15, 2015 12:15
More advanced ThreadBox with affinity guards
// This is a class that attempts to stop you accessing variables outside a lock.
//
// It does not do a perfect job, but can catch some common kinds of mistake, in
// particular when you accidentally try to work with objects inside closures that
// end up running later, outside the locked region (or in a different thread).
// EXAMPLE
val bank = ThreadBox(object {
val accounts by arrayListOf(10, 0, 0, 0).guard()
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=channel:nixos-18.09 -i ghci -p "haskellPackages.ghcWithPackages (p: [p.monoidal-containers p.average])"
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MonadComprehensions #-}
import Control.Applicative ( Alternative(..) )
import Control.Monad.Trans.Cont
import Data.Map.Monoidal ( MonoidalMap )
import qualified Data.Map.Monoidal as Map
@benjie
benjie / README.md
Last active January 17, 2023 15:16
Long Live CoffeeScript and Long Live ES6

Long Live CoffeeScript and Long Live ES6

Clearly ES6 is a huge improvement over ES5, and tools like [6to5][] allow us to use these cool features now. I was reading [Replace CoffeeScript with ES6][replace coffeescript] by [Blake Williams][] and thought it was a great summary of how ES6 solves many of the same problems that CoffeeScript solves; however I'd like to comment on a few of Blake's points and talk about why I'll be sticking with CoffeeScript.

Classes

Classes in ES6 (like many of the syntax changes in ES6) are very similar to the CoffeeScript equivalent. To support browsers that are not fully ES5 compliant (e.g. IE8-), however, we still can't really use getters/setters, so ignoring these the comparison is:

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

Minecraft on Apple Silicon

In this gist, you can find the steps to run Minecraft 1.16.4 natively on Apple Silicon (AS), without needing Rosetta 2 translation of the dependencies (mainly LWJGL and related libraries).

While it's possible to use a launcher like MultiMC to have a prettier way to run the game on AS, it requires installing even more dependencies (like QT) which take time and are difficult to distribute. Therefore, I've put together a command line-based launcher tool using a couple shell & Python scripts.

To get up and running quickly, follow the steps below. Otherwise, for more detail, watch my YouTube video.

Download my package

@andybarilla
andybarilla / hover.py
Last active August 5, 2023 06:21
DDNS Script for Hover (using their unofficial API)
#!/usr/bin/env python
"""hover.py: Provides dynamic DNS functionality for Hover.com using their unofficial API.
This script is based off one by Dan Krause: https://gist.github.com/dankrause/5585907"""
__author__ = "Andrew Barilla"
__credits__ = ["Andrew Barilla", "Dan Krause"]
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Andrew Barilla"