Skip to content

Instantly share code, notes, and snippets.

View 5alamander's full-sized avatar

ForgiveMyAwfulEngilsh 5alamander

View GitHub Profile
(*
ParserLibrary.fsx
Final version of a parser library.
Related blog post: http://fsharpforfunandprofit.com/posts/understanding-parser-combinators-3/
*)
module TextInput =
open System
@5alamander
5alamander / authorize_job_poster_1.ex
Created April 21, 2017 14:48 — forked from mileszs/authorize_job_poster_1.ex
Use new fun toys or not?
defmodule ElixirJobBoard.Plugs.AuthorizeJobPoster do
import Plug.Conn
import Phoenix.Controller, only: [put_flash: 3, redirect: 2]
alias ElixirJobBoard.Repo
alias ElixirJobBoard.User
alias ElixirJobBoard.Job
def init(opts), do: opts
@5alamander
5alamander / template.clj
Created March 13, 2017 09:42
A cool template in clojure
(ns console-demo.template)
(def delimiters ["<%" "%>"])
(def parser-regex
(re-pattern
(str "(?s)\\A"
"(?:"
"(.*?)" (first delimiters) "(.*?)" (last delimiters)
")?"
@5alamander
5alamander / nanomsg.org
Last active January 7, 2017 15:23
nanomsg examples

nanomsg

Pipeline

Code

@5alamander
5alamander / server.ex
Created November 20, 2016 17:06 — forked from adnils/server.ex
Elixir TCP echo server
defmodule Echo.Server do
def start(port) do
tcp_options = [:binary, {:packet, 0}, {:active, false}]
{:ok, socket} = :gen_tcp.listen(port, tcp_options)
listen(socket)
end
defp listen(socket) do
{:ok, conn} = :gen_tcp.accept(socket)
spawn(fn -> recv(conn) end)
@5alamander
5alamander / js_csp.d.ts
Created November 9, 2016 10:40
typescript: this is a dts file for js-csp
declare module 'js-csp' {
namespace Boxes {
class Box<T> {
value: T
constructor(value: T)
}
class PutBox<T> {
handler: Handlers.HandlerType
value: T
@5alamander
5alamander / node_readline.js
Created November 8, 2016 10:18
a prompt with history
// IMPORTANT: choose one
var RL_LIB = "libreadline"; // NOTE: libreadline is GPL
//var RL_LIB = "libedit";
var HISTORY_FILE = require('path').join(process.env.HOME, '.mal-history');
var ffi = require('ffi'),
fs = require('fs');
var rllib = ffi.Library(RL_LIB, {
@5alamander
5alamander / gulpfile.coffee
Last active October 31, 2016 13:03
customize gulp file
through = require('through2')
gulp.task 'src', ->
gulp.src './src/*.coffee'
.pipe coffee({bare: true})
.pipe gulp.dest('./dest/')
.pipe through.obj((file, encoding, callback) ->
callback(null, doSomethingWithTheFile(file))
)
.on 'error', gutil.log
# bash proxy
# export HTTP_PROXY=http://127.0.0.1:16823/
# export http_proxy=http://127.0.0.1:16823/
# export HTTPS_PROXY=https://127.0.0.1:16823/
# export https_proxy=https://127.0.0.1:16823/
# export ALL_PROXY=http://127.0.0.1:16823/
# export all_proxy=https://127.0.0.1:16823/
# go path
export GOROOT=/usr/local/opt/go/libexec
@5alamander
5alamander / csp.cs
Last active February 15, 2017 14:12
初版csp_for_unity。TODO: 1,处理异常时,在unity线程和系统线程处理方式不一致,2.系统线程中无法使用 timeout,3.外部无法手动停止系统线程中的某个coroutine,4.只使用了1个外部线程。更新:使用linkedlist替代queue,闲置时挂起线程。
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
namespace Sa1 {
/// <summary>
/// ins: do not use timeout in the csp.subthread