Skip to content

Instantly share code, notes, and snippets.

View aslushnikov's full-sized avatar
🚀
Going through all the e-mails and notifications

Andrey Lushnikov aslushnikov

🚀
Going through all the e-mails and notifications
View GitHub Profile
1 // a geometry vertice
2 struct Vertice {
3 1: double x,
4 2: double y,
5 3: double z
6 }
7
8 // geometry itself
9 struct Geometry {
10 1: list<Vertice> vertices
@aslushnikov
aslushnikov / gist:2570185
Created May 1, 2012 18:14
convex shell on JS
function Point(x, y) {
this.x = x;
this.y = y;
return this;
}
var a = [
new Point(0, 3)
, new Point(1, 1)
, new Point(1, 3)
@aslushnikov
aslushnikov / gist:3353206
Created August 14, 2012 21:30
small sample
public class Sample {
public int bar;
public void foo() {
#StarTrek SomeShittyLog4jLogger.info
if (bar == 1998) {
System.out.println("Google");
} else {
bar = 1998;
@aslushnikov
aslushnikov / gist:3353295
Created August 14, 2012 21:41
bash sample
#!/bin/bash
set -x
bar=0;
@aslushnikov
aslushnikov / gist:5868416
Created June 26, 2013 15:32
running CodeMirror modes in node
var vm = require('vm')
, fs = require('fs')
CodeMirror = require('./runmode.node.js');
var text = fs.readFileSync("./javascript.js", "utf-8");
vm.runInThisContext(text);
CodeMirror.runMode("var i = 0;", "text/javascript", function() {
console.log(arguments);
});
@aslushnikov
aslushnikov / gist:6240417
Created August 15, 2013 12:24
Code snippet to generate a contrast colors for some object types. Consider you have a text written in different fonts, and you want to highlight every character with its own color
function generatePalette()
{
// example of test input
var fontsPalette = {
"Times New Roman": "",
"Arial": "",
"Verdana": ""
};
var fonts = Object.keys(fontsPalette);
var amount = Object.keys(fonts).length;
@aslushnikov
aslushnikov / gist:6876287
Last active December 24, 2015 22:59
Javascript number trick See http://www.2ality.com/2013/10/safe-integers.html to figure out what's going on
var magic = 10000026136623930;
console.log(magic % 2 === 0); // true
console.log((magic + 1) % 2 === 0); // true... WHAT
// See http://www.2ality.com/2013/10/safe-integers.html
// to figure out what's going on
@aslushnikov
aslushnikov / rollcm.sh
Last active January 3, 2016 03:19
A small script to roll CodeMirror.
#!/bin/bash
set -e
function copyFiles
{
cd $downstreamFolder
for file in *.*; do
fileName=$(basename $file)
if [[ $fileName == $generatedFile ]]; then
continue;
@aslushnikov
aslushnikov / example-usage.js
Last active September 26, 2018 07:39
definition of `fake` function to emulate keyboard events in CodeMirror instance. Useful for testing; depends on availability of `codeMirror.triggerOnKeyPress/triggerOnKeyUp` events.
var editor = new CodeMirror({ /* ... */ });
fake(editor, "("); // if you have closebrackets.js addon switched on, this will actually generate "()"
fake(editor, "enter"); // all the crazy indenting logic will be used
fake(editor, "e"); // just letter "e"
fake(editor, 48); // 0
fake(editor, "leftArrow", ["ctrlKey", "shiftKey"]);
@aslushnikov
aslushnikov / unused.sh
Last active August 29, 2015 13:56
Find private functions that have never been used in inspector front-end
#!/bin/bash
set -e
if (( $# < 1 )); then
echo "Specify filename to analyze"
exit 1
fi
fileName=$1