Skip to content

Instantly share code, notes, and snippets.

View bombless's full-sized avatar

York Xiang bombless

  • Guangzhou, China
View GitHub Profile
@kezabelle
kezabelle / gist:4959657
Created February 15, 2013 10:49
Quick and dirty nested accordian in jQuery, a reminder for myself.
/*
* Taken from http://sower.com.au/2011/06/jquery-multilevel-accordion-in-10-lines-of-code/
*/
$(document).ready(function() {
$('.menu li ul').hide();
$('.menu li a').click(
function(evt) {
evt.preventDefault();
evt.stopPropagation();
var openMe = $(this).next();
/*
* Taken from http://sower.com.au/2011/06/jquery-multilevel-accordion-in-10-lines-of-code/
*/
$(document).ready(function() {
$('.menu li ul').hide();
$('.menu li a').click(
function(evt) {
evt.preventDefault();
evt.stopPropagation();
var openMe = $(this).next();
@wintercn
wintercn / HTMLLexicalParser.js
Last active September 2, 2024 04:01
HTML语法分析器模型
function StartTagToken(){
}
function EndTagToken(){
}
function Attribute(){
}
@Mr-Byte
Mr-Byte / linq.rs
Last active August 13, 2017 18:00
Proof of concept macro to implement LINQ syntax in rust.
macro_rules! query(
(from $v:ident in $c:ident $(where $mw:expr)* select $ms:expr) =>
($c.filter_mapped(|&$v| if(true $(&& $mw)*) { Some($ms) } else { None }))
)
fn main()
{
let nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let result1 = query!(from x in nums select x * 2);
@redraiment
redraiment / Y Combinator 简介
Last active December 23, 2020 07:44
Y Combinator (Fixed-point Combinator) 不动点组合子
Y组合子是Lambda演算的一部分,也是函数式编程的理论基础。
它是一种方法/技巧,在没有赋值语句的前提下定义递归的匿名函数。
即仅仅通过Lambda表达式这个最基本的“原子”实现循环/迭代。
颇有道生一、一生二、二生三、三生万物的感觉。
虽然Y组合子在理论上很优美,但在实际开发中并不会真的用到。
想要了解Y组合子是什么,请参见维基百科:http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator
或者知乎上的回答:http://www.zhihu.com/question/20115649
@abovethewater
abovethewater / init.coffee
Last active October 7, 2015 14:34
Enabling bracket matching without auto closing brackets in atom
BracketMatcherView = require '/Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/bracket-matcher-view.js'
atom.workspaceView.eachEditorView (editorView) =>
if editorView.attached and editorView.getPane()?
new BracketMatcherView(editorView)
@aturon
aturon / hkt-via-ai-take-2.rs
Last active August 29, 2015 14:05
An updated HKT encoding
trait StarToStar<Input> {
type Output;
}
type Apply<Name, Elt> where Name: StarToStar<Elt> = Name::Output;
struct Vec_;
struct DList_;
impl<T> StarToStar<T> for Vec_ {
type Output = Vec<T>;
@miketang84
miketang84 / main.js
Created December 29, 2014 14:43
websocket chatroom
extern crate websocket;
//extern crate openssl;
use std::comm;
use std::thread::Thread;
use std::io::{Listener, Acceptor};
use websocket::{WebSocketServer, WebSocketMessage};
//use websocket::client::WebSocketClient;
use websocket::header::WebSocketProtocol;
//use openssl::ssl::{SslContext, SslMethod};
% rustc goodbye.rs && rustc -L . beatles.rs && ./beatles
goodbye.rs:10:25: 10:29 warning: unused import, #[warn(unused_imports)] on by default
goodbye.rs:10 use syntax::ext::base::{self, ExtCtxt, MacResult, DummyResult, MacEager};
^~~~
I don't know why you say goodbye, I say hello