Skip to content

Instantly share code, notes, and snippets.

View yshui's full-sized avatar
🪲

Yuxuan Shui yshui

🪲
View GitHub Profile
@yshui
yshui / gist:11348787
Last active August 29, 2015 14:00
UTF8 to Unicode, not-so-IOCCC style
#define s "U+%04llX\n"
#define G(x) goto x
unsigned long long cp;
main(a,_,c){if(c)G(y);
if(~_&0x40)G(e);if(_&(1<<a))G(x);
return printf(s,cp+((_&~(-1<<a))<<6*(6-a)));
x:if((c=getchar())&0x40)G(e);
cp=(cp<<6)+(c&0x3f);return main(a-1,_,0);
y:if(!~(_=getchar()))return 0;
_&0x80?main(6,_,cp=0):printf(s,_);return main(a,_,c);
From cae2e1a925c52449fd13c2dce7dacbf9d7b9725a Mon Sep 17 00:00:00 2001
From: Yuxuan Shui <yshuiv7@gmail.com>
Date: Sun, 30 Mar 2014 03:58:12 +0800
Subject: [PATCH 1/2] core: Add a User= to scopes.
Conflicts:
src/core/scope.c
---
src/core/dbus-scope.c | 13 +++++++++++++
src/core/load-fragment-gperf.gperf.m4 | 1 +
#![feature(box_syntax)]
use std::ops::DerefMut;
use std::ops::Deref;
#[derive(Show)]
struct List<T> {
car: T,
cdr: Option<Box<List<T>>>,
}
@yshui
yshui / a.c
Created August 10, 2015 21:45
GCC fail
int k(int a) {
int b = a;
switch(a) {
case 1:
b+=1;break;
case 2:
b+=2;break;
case 3:
b+=3;break;
case 4:
#!/usr/bin/dmd -run
import std.stdio, std.file, std.path, std.string, std.conv, std.math, std.container, std.algorithm, std.parallelism, std.range;
string filesize(double size){
string units = "KMGT";
double left = cast(double)size.abs();
int unit = -1;
while(left > 1100 && unit < 3){
@yshui
yshui / drag_test.c
Created March 13, 2012 13:18
Test case for window dragging
/* Simple XCB application to test configure request handling */
/* Run this problem, enable floating mode, and press a key while the window is focused.
* The window will follow the mouse */
/* to compile it use :
gcc -Wall x.c -lxcb
*/
#include <xcb/xcb.h>
#include <stdio.h>
#include <stdlib.h>
@yshui
yshui / test.c
Created March 13, 2012 13:51
small test case
/* Simple XCB application drawing a box in a window */
/* to compile it use :
gcc -Wall x.c -lxcb
*/
#include <xcb/xcb.h>
#include <stdio.h>
#include <stdlib.h>
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, int *r) {
xcb_void_cookie_t cookie;
@yshui
yshui / render_c_draft.patch
Created August 8, 2012 11:15
render.c cleanup? - Draft
From f10f9cbd90f323dcc66c130cd1f839de3b75ec67 Mon Sep 17 00:00:00 2001
From: darkraven <drdarkraven@gmail.com>
Date: Wed, 8 Aug 2012 19:38:12 +0800
Subject: [PATCH] draft
---
src/render.c | 339 ++++++++++++++++++++++++++++-------------------------------
1 file changed, 161 insertions(+), 178 deletions(-)
diff --git a/src/render.c b/src/render.c
@yshui
yshui / logic-change.patch
Created August 9, 2012 07:02
render.c messup
From 434b04aff25d7226e71c4d7f2387e7dd30c80b83 Mon Sep 17 00:00:00 2001
From: darkraven <drdarkraven@gmail.com>
Date: Thu, 9 Aug 2012 15:01:10 +0800
Subject: [PATCH 1/2] logic changes
---
src/render.c | 225 ++++++++++++++++++++++++++---------------------------------
1 file changed, 97 insertions(+), 128 deletions(-)
diff --git a/src/render.c b/src/render.c
//template<typename T>
//bool Foo(T a, T b) {
// T c = a + b;
// return a == c;
//}
//
//Expands to:
//------------- begin -------------
#include <iostream>