Skip to content

Instantly share code, notes, and snippets.

View bombless's full-sized avatar

York Xiang bombless

  • Guangzhou, China
View GitHub Profile
@corytodd
corytodd / csharp_gdi_print.cs
Created June 13, 2018 02:59
GDI Printing Example for C#
#region Win32 GDI
private void btnTextDrawCenter_Click(object sender, RoutedEventArgs e)
{
var doc = new PrintDocument()
{
PrintController = new StandardPrintController(),
};
doc.OriginAtMargins = false;
doc.PrinterSettings.PrinterName = CurrentPrinter;
doc.PrintPage += (s, args) =>
@joyrexus
joyrexus / README.md
Last active August 6, 2024 16:07
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@davegurnell
davegurnell / TypeclassDemo.scala
Created October 6, 2015 14:53
Example of the type class pattern in Scala
object TypeclasseDemo {
// The parts of the type class pattern are:
//
// 1. the "type class" itself -- a trait with a single type parameter;
//
// 2. type class "instances" for each type we care about,
// each marked with the `implicit` keyword;
//
// 3. an "interface" to the type class -- one or more methods
% 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
@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};
@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>;
@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)
@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
@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);