Skip to content

Instantly share code, notes, and snippets.

@Trufi
Trufi / toInt64.js
Last active August 11, 2017 07:22
Low and hi bytes (int32) to int64
// hi * 2 ^ 32 + low
const BASE_LENGTH = 5;
const BASE = 1e5;
const LENGTH = 4; // [20 / 5]
function toArray(x) {
return [x % BASE, Math.floor(x / BASE) % BASE, Math.floor(x / BASE / BASE), 0];
}
function multiply232(a) {
@Trufi
Trufi / gist:982e2d5f7020ccbffd703cf692612a11
Last active June 29, 2017 11:13
demo systemd commands

Запуск сервиса: sudo service 8874-tile-server-2 start

Класть кофинг для systemd в папку /etc/systemd/system.
Называть 8874-tile-server-2.service.
Писать в него:

[Service]
Restart=always
WorkingDirectory=/var/www/applications/8874-tile-server-2
ExecStart=/var/www/applications/8874-tile-server-2/tile-server --port=8874
@Trufi
Trufi / webgl-log-error.js
Last active January 29, 2021 10:34
WebGL log error
const compileShader = WebGLRenderingContext.prototype.compileShader;
WebGLRenderingContext.prototype.compileShader = function(shader) {
compileShader.call(this, shader);
if (!this.getShaderParameter(shader, this.COMPILE_STATUS)) {
console.log(this.getShaderInfoLog(shader));
}
};
@Trufi
Trufi / jira print filter.js
Last active May 31, 2018 10:04
jira print filter
document.getElementsByTagName('header')[0].remove();
var types = [
'result-header',
'issuetype',
'project',
'subtasks',
'fixVersions',
'assignee',
'resolution',
@Trufi
Trufi / .prettierrc
Last active November 13, 2019 06:32
VSCode
{
"printWidth": 100,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"semi": true,
"arrowParens": "always",
"jsxSingleQuote": true,
"endOfLine": "lf"
}
@Trufi
Trufi / PriorityQueue.js
Created October 24, 2016 05:03
PriorityQueue
class Item {
constructor(priority, key) {
this.priority = priority;
this.key = key;
}
}
export default class MinPriorityQueue {
constructor() {
this._queue = [];
@Trufi
Trufi / gist:5d178090d627e11fb927
Created November 9, 2015 11:14
webgl simple cube
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>cube</title>
<style>
html, body {
margin: 0;
width: 100%;
@Trufi
Trufi / gist:79b8b7520280e4b3471f
Last active November 9, 2015 11:13
webgl simple triangle
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Triangle</title>
<style>
html, body {
margin: 0;
width: 100%;
var colors = {};
colors.hslToRgb = function(hsl) {
var h = hsl[0];
var s = hsl[1];
var l = hsl[2];
var m1,
m2;
/* Some simple corrections for h, s and l. */