Skip to content

Instantly share code, notes, and snippets.

View be5invis's full-sized avatar

Belleve be5invis

View GitHub Profile
@be5invis
be5invis / gist:651379
Created October 28, 2010 13:47
A Better <home> key for windows users
function HomeBind(offset)
let cursor=getpos('.')
let s0=getline(line('.'))
let s1=substitute(s0, "^\\s\\+", "", "")
let x=len(s0)-len(s1)+1
if col('.') == x-a:offset
let x=1
endif
call setpos('.', [cursor[0], cursor[1], x, cursor[3]])
endfunction
@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){
@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
@be5invis
be5invis / k-types.txt
Last active December 31, 2015 18:29
Conceptional language + type system
// data types
type[T] Point {
data x : T
data y : T
}
type IntPoint = Point[Integer]
// complex concepts
type[T <= Differable] DifferenceOf {