Skip to content

Instantly share code, notes, and snippets.

View Linrstudio's full-sized avatar
🌴
On vacation

xyz Linrstudio

🌴
On vacation
View GitHub Profile
@Linrstudio
Linrstudio / chunking-regex.ts
Created August 15, 2024 10:45 — forked from hanxiao/testRegex.js
Use regex to do chunking by using all semantic cues
// Used in https://jina.ai/tokenizer (Aug. 14th version)
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 6;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
const MAX_HTML_HEADING_ATTRIBUTES_LENGTH = 100;
const MAX_LIST_ITEM_LENGTH = 200;
const MAX_NESTED_LIST_ITEMS = 5;
const MAX_LIST_INDENT_SPACES = 7;
const MAX_BLOCKQUOTE_LINE_LENGTH = 200;
{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[220.741,37.184],[225.501,35.896],[228.749,32.36800000000001],[229.981,27.216000000000008],[228.749,22.12],[225.501,18.592],[220.741,17.304],[215.981,18.592],[212.677,22.12],[211.501,27.216000000000008],[212.677,32.36800000000001],[215.981,35.896],[220.741,37.184],[220.741,37.184],[220.741,37.184]],"i":[[0,0],[-1.380999999999972,0.8586999999999989],[-0.7839999999999918,1.493299999999991],[0,1.903999999999996],[0.8220000000000027,1.493299999999991],[1.382000000000062,0.8586999999999989],[1.79200000000003,0],[1.418999999999983,-0.8586999999999989],[0.8220000000000027,-1.493300000000005],[0,-1.904000000000011],[-0.7839999999999918,-1.5307000000000102],[-1.380999999999972,-0.8586999999999989],[-1.754000000000019,0],[0,0],[0,0]],"o":[[1.79200000000003,0],[1.382000000000062,-0.8586999999999989],[0.8220000000000027,-1.5307000000000102],[0,-1.904000000000011],[-0.7839999999999918,-1.493300000000005],[-1.380999999999972,
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
};
Math.ctg = function(val) {
return 1/Math.tan(val);
}
@Linrstudio
Linrstudio / qs.js
Created December 28, 2015 02:07 — forked from drewlesueur/qs.js
// code taken from visionmedias node-querystring
var qs = (function () {
var qs = {}
/**
* Object#toString() ref for stringify().
*/
var toString = Object.prototype.toString;
/**
.flex {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.flex.flex--reverse {
-webkit-box-orient: horizontal;
@Linrstudio
Linrstudio / hello-apple.md
Created October 20, 2015 06:44
solutions for window.innerWidth / innerHeight issue in iOS9

iOS9 returns double the value for window.innerWidth & window.innerHeight
The versions that are concerned are: 9.0.0, 9.0.1, 9.0.2

A few people got mad on twitter:

window.innerWidth in iOS 9 Safari returns double the number it did in iOS 8? Is this real life? tell me no — @rachsmithtweets
iOS9 Safari has the most insane bug where window.innerWidth / innerHeight is *sometimes* twice as large as it should be. ughhhh. !? — @mattdesl

iOS9 innerWidth/innerHeight is having a lot of fun these days — @ayamflow

@Linrstudio
Linrstudio / iOS: Fixed position elements on input focus
Last active August 29, 2015 14:26
iOS: Fixed position elements on input focus
$(document).ready(function() {
$("input, select, textarea").on('focus', function() {
$("#header").css({
'position': 'absolute',
'top': $(document).scrollTop()
});
focusing = true;
})
$("input, select, textarea").on('blur', function() {
$("#header").css({
var $preventAllEvents = $('input');
// The magic code
var oldAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(eventName, eventHandler)
{
oldAddEventListener.call(this, eventName, function(event) {
if(!$preventAllEvents.is(':checked'))
eventHandler(event);
I have the script events_spy.js:
(function(original) {
Element.prototype.addEventListener = function(type, listener,
useCapture) {
if (typeof (this._handlerTypes) == 'undefined') {
this._handlerTypes = {};
}
this._handlerTypes[type] = true;
return original.apply(this, arguments);