Skip to content

Instantly share code, notes, and snippets.

View be5invis's full-sized avatar

Belleve be5invis

View GitHub Profile
@be5invis
be5invis / answer.c
Created November 25, 2010 11:48
An answer for a (fake)loli.
#define digit(p) ('0' <= *(p) && *(p) <= '9')
char* a[1000];
int n = 0;
void fetch(char* p){
while(*p && !digit(p)) p++;
if(*p){
char* start = p;
while(*p && digit(p)) p++;
a[n] = start; n++;
if(*p) *p = 0, fetch(++p);
@be5invis
be5invis / guess.moe
Created March 14, 2012 14:10
An solution of Vczh's problem
var MakeTest(a0, d):
var j = 0;
return (x) =>
def r = a0 + d * j;
j += 1;
return x === r
def guess(test):
var counter = 0
for var segment in 1..infinity:
@be5invis
be5invis / enumComp.moe
Created March 24, 2012 09:03
Enumerator comprehension monad
-- Enumerator comprehension monad
var ecSchemata = [yield: fYield, return: fReturn, bind: fBind]
where
fReturn = Enumerable function(x):
if(x != undefined)
enumeration.yield! x
fYield(x) = x
fBind = Enumerable function(list, callback):
for(var x in list)
for(var y in callback x)
@be5invis
be5invis / mergeSpaces.moe
Created March 29, 2012 12:29
Answer for Ninputer: merge spaces
def rest(s) = s.slice 1
def mergeSpaces(s) = phase_normal s
where phase_normal(s) = piecewise
when(not s) s
when(s[0] == ' ') s[0] + phase_space rest s
otherwise s[0] + phase_normal rest s
phase_space(s) = piecewise
when(not s) s
when(s[0] == ' ') phase_space rest s
@be5invis
be5invis / gist:2566627
Created May 1, 2012 09:10
Moescript source map example
function F1$_(){
var Tp$_, Tq$_, T11$_, T12$_;
var ecSchemata$, item$, mktable$, t$;
//MoeMap// var ecSchemata = [yield: fYield, return: fReturn, bind: fBind]
//MoeMap// where
ecSchemata$ = (function F2$_(){
var fBind$, fReturn$, fYield$;
//MoeMap// fReturn = Enumerable function(x):
fReturn$ = Enumerable$({build:function(SCHEMATA$_){return function(x$){
var T4$_, T5$_, T6$_, T7$_;
<dict>
<key>match</key>
<string>[$*,£¥·‘“〈《「『【〔〖〝﹗﹙﹛$(.[{£¥]*[&#x3000;-&#x9fff;][!%),.:;>?¢¨°·ˇˉ―‖’”„‟†‡›℃∶、。〃〆〈《「『〕〗〞︵︹︽︿﹃﹘﹚﹜!"%'),.:;?]`|}~ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻]*</string>
<key>name</key>
<string>meta.cjkword</string>
</dict>
@be5invis
be5invis / explain.js
Last active October 13, 2015 14:57
Javascript Engines DO optimize integer operations.
function bench1(n){
for(var i = 0; i < n; i++) ;
}
function bench2(n){
for(var i = 0.5; i < n; i++) ;
}
function bench3(n){
for(var i = Math.random(); i < n; i++) ;
}
function bench4(n){
function $(C,E,K){if(!(C instanceof Array))return K("string"==typeof C?
E[C]:C);switch(C[0]){case"lambda":return K(function(K){return function(
){for(var e=Object.create(E),u=0;u<C[1].length;u++)e[C[1][u]]=arguments
[u];return $(C[2],e,K)}});case"if":return $(C[1],E,function(e){return e
?$(C[2],E,K):$(C[3],E,K)});case"callcc":return $(C[1],E,function(C){var
E=function(){return function(C){return K(C)}};return C(E)(E)});case "'"
:return K(C[1]);default:return $c(C,E,K)}}function $c(C,E,K){return $(C
[0],E,function(e){return $$(C.slice(1),E,function(C){return e(K).apply(
null,C)})})}; function $$(C,E,K) {return C.length?$(C[0],E,function(e){
return $$(C.slice(1),E,function(C){return K(C?[e]:[e].concat(C))})}):K(
@be5invis
be5invis / zoom2x.ps1
Last active December 9, 2015 22:02
修本专用放大脚本
$input = $args[0]
$output = $input -replace '.(gif|png|jpg|jpeg)$','.2x.png'
echo "$input --> $output"
# 通过叠加在黑色和白色背景上来处理半透明的图片
# 因为我又一次真特么要放大透明图
$temp_black = [System.IO.Path]::GetTempFileName() + '.png'
$temp_black_2x = [System.IO.Path]::GetTempFileName() + '.png'
$temp_white = [System.IO.Path]::GetTempFileName() + '.png'
$temp_white_2x = [System.IO.Path]::GetTempFileName() + '.png'
# convert 为 imagemagick
@be5invis
be5invis / scroll.ahk
Created September 15, 2013 14:05
DPI-aware FocuslessScroll
; Modified by Belleve Invis
; In order to support High DPI environment
; FocuslessScroll by Scoox
; Source: http://www.autohotkey.com/board/topic/6292-send-mouse-scrolls-to-window-under-mouse/?p=398492
; Modifications by Geoff Stokes
;Directives
#NoEnv
#SingleInstance Force