Skip to content

Instantly share code, notes, and snippets.

View andrienko's full-sized avatar
🇺🇦
~

Ilia Andrienko andrienko

🇺🇦
~
View GitHub Profile
@andrienko
andrienko / examplefile.dae
Created May 17, 2022 13:33
xmldom-qsa failing XML file
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>three.js Collada Exporter</authoring_tool>
</contributor>
<created>2022-05-17T12:06:03.572Z</created>
<modified>2022-05-17T12:06:03.572Z</modified>
<up_axis>Y_UP</up_axis>
</asset>
@andrienko
andrienko / monacoDragAndDropProvider.ts
Last active April 30, 2024 18:00
Monaco drag and drop provider
import React from 'react';
import { editor } from 'monaco-editor';
import IMouseTarget = editor.IMouseTarget;
import IStandaloneCodeEditor = editor.IStandaloneCodeEditor;
import IContentWidget = editor.IContentWidget;
const { ContentWidgetPositionPreference } = editor;
export type TDropHandler = (e: React.DragEvent, target: IMouseTarget, instance: IStandaloneCodeEditor) => void;
export type TInstanceGetter = () => IStandaloneCodeEditor;
@andrienko
andrienko / index.fakeloading.js
Last active November 9, 2018 13:30
Minimal mobx store app with observables
import React from "react";
import ReactDOM from "react-dom";
import { observable } from "mobx";
import { observer } from "mobx-react";
// Store
class Store {
@observable isLoading = false;
@andrienko
andrienko / webpack.config.js
Created November 7, 2018 15:52
This is my webpack config. There are many webpack configs, and this one is mine!
/* eslint-disable */
var path = require('path');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var WriteFilePlugin = require('write-file-webpack-plugin');
var cssnano = require('cssnano');
var autoprefixer = require('autoprefixer');
var cssLoaderUse = function(asModules) {
return [
@andrienko
andrienko / percentage.php
Created October 10, 2016 01:32
PHP 5.2. Calculating percentage using largest remainder method (bit tricky)
<?php
function calculate_percentage($aw,$tp=0,$t=0){
foreach($aw as $a) $t += $a['votes'];
foreach($aw as &$a)$tp += floor($a['percentage'] = $a['votes'] / $t * 100);
uasort($aw, 'sort_by_remainder');
foreach ($aw as &$v) $v['percentage'] = ($tp++ < 100) ? ceil($v['percentage']) : floor($v['percentage']);
ksort($aw);
return $aw;
}
@andrienko
andrienko / extend.js
Created March 30, 2016 14:37
Yet another jquery-like deep extend implementation
module.exports = (function () {
var extend_single = function (destination, source, deep) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
if (deep && typeof destination[key] == 'object' && typeof source[key] == 'object') {
destination[key] = extend_single(destination[key], source[key], deep);
} else {
destination[key] = source[key];
var e = encodeURIComponent;
var d = decodeURIComponent;
var paramsToURI = function(params){
var uri_components = [];
for(var i in params){
if(params.hasOwnProperty(i)) {
uri_components.push(e(i) + '=' + e(params[i]));
}
}
@andrienko
andrienko / gist:14331b88b0e877087a2f
Last active August 29, 2015 14:21
iOS safe cookie session start
function cookiesafe_session_start(){
$sn = session_name();
if (isset($_COOKIE[$sn])) {
$sessid = $_COOKIE[$sn];
} else if (isset($_GET[$sn])) {
$sessid = $_GET[$sn];
} else {
session_start();
return false;
}
<?php
// Loading plish from hard drive and getting plish dimentions
$plish = imagecreatefrompng('plish.png');
list($x,$y) = array(imagesx($plish),imagesy($plish));
// --- Creating black image with dots
// Creating new image (black by default) with dimentions of a plish
$dots = imagecreatetruecolor($x,$y);
@andrienko
andrienko / bandcamp
Last active August 29, 2015 14:12
Get links to all tracks on bandcamp page in pretty form
document.body.innerHTML = ((function(d,o){
o.y=new Date(d.album_release_date).getFullYear();
o.r=['<h1>'+ o.a([d.artist,o.y,d.current.title].join(' - '),d.url)+'</h1>'];
(o.u = d.artFullsizeUrl) && o.r.push('<img src="'+ o.u+'"/>');
d.trackinfo.forEach(function(t){
for(o.i in t.file){}
o.r.push(o.a((""+t.track_num).replace(/^(\d{1})$/g,'0$1') + ' - '+ t.title+'.mp3',t.file[o.i]));
});
return o.r.join("<br/>\n");