Skip to content

Instantly share code, notes, and snippets.

View embarq's full-sized avatar
🕶️
Working hard

Li Ihor embarq

🕶️
Working hard
View GitHub Profile
"use strict";
let getErrorRank = err => {
let rankCounter = 0;
let ranks = new Array(8).fill().map((item, i) => 1 / Math.pow(10, i)).slice(1);
for (let i = 0; i < ranks.length; i++) {
if (err < ranks[i]) {
rankCounter++;
} else {
@embarq
embarq / handleFormResponse.js
Created October 7, 2016 08:45
Google AppsScript macro for Google Forms and Google Sheets. Script should be installed by running "Initialize" function. Sorts form's response data by user gender. Append data after last row that contains any data(Prevent unnecessary whitespace between rows)
function isSheetExist(sheetName) {
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName) != null;
}
function formResponseFilter(e) {
if (!e) throw new Error("Please go the Run menu and choose Initialize");
try {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var base = ss.getSheets()[0];
var sheet = null;
@embarq
embarq / index.html
Created October 11, 2016 11:28
News blog
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>News</title>
<link href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAAAAAAPvzoEf8+ajf8O2g/PXyo9z89qSF9eCKB/TfiQb89qSC9vKj2fDtoPj8+ajb+/OfRQAAAAAAAAAAAAAAAAAAAAD9+qjR4eGZ/9XVkf/X15L/+/ur//z1omf89aJn+/ur/9fXkv/V1ZH/4eGa//36qNAAAAAAAAAAAAAAAAD14owX9fSm/tXVkf/V1ZH/1dWR//Pzpf/896WA/PelgPPzpf/V1ZH/1dWR/9XVkf/19Kb+9eKMFgAAAAAAAAAA+/KfT+7uov/V1ZH/1dWR/9XVkf/29qj/+/KfUfvzn1L29qj/1dWR/9XVkf/V1ZH/7u6i//vyn04AAAAAAAAAAPz3pYPo6J7/1dWR/9XVkf/Z2ZT//vyr+fXijBH14owS/vyr+djYk//V1ZH/1dWR/+jonv/896WCAAAAAAAAAAD155G2xrta/9XVkf/V1ZH/49+T//35p7sAAAAAAAAAAP35qLzj35T/1dWR/9XVkf/Gu1v/9eiStQAAAADx1X0CyrRH6Ma/Zv/V1ZH/1dWR/8W6Wf/u3YN5AAAAAAAAAADv3oR5xbpZ/9XVkf/V1ZH/xr9l/8u1SOjx1X0C7dF4KrmoNv/U1I7/1dWR/9XVkf/QzHr/x7FCmwAAAAAAAAAAx7FCmtDMev/V1ZH/1dWR/9TUjv+5qDX/7dF4KeDHZnbDu1z/1dWR/9XVkf/V1ZH/2dmU/9XBWq0AAAAAAAA
@embarq
embarq / decompose.cpp
Created October 11, 2016 12:58
LU-secomposition
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int n = 4;
void lu(float[n][n], float[n][n], float[n][n], int n);
@embarq
embarq / stageByExtension.sh
Created October 14, 2016 14:27
Recursively stage files by pattern
git ls-files -co --exclude-standard | grep '\.java$' | xargs git add
window.onload = function () {
// this simple machine prints "Hello" and stops
var instance = new Machine({
// a finite, non-empty set of states
states : [0, 1, 2, 3, 5],
// a finite, non-empty set of the tape alphabet/symbols
alphabet : ['_', 'H', 'e', 'l', 'o'],
// the blank symbol (the only symbol allowed to occur on the
// tape infinitely often at any step during the computation)
blank : '_',
@embarq
embarq / authentication.ts
Created November 1, 2016 20:43 — forked from btroncone/authentication.ts
Angular 2 application role access decorator, wrapping built in CanAccess functionality. Prevents view transitions when user roles are not appropriate.
import { Injectable } from 'angular2/core';
import { Storage } from './storage';
import { CurrentUser } from '../interfaces/common';
@Injectable()
export class Authentication{
private _storageService : Storage;
private _userKey : string = "CURRENT_USER";
constructor(storageService : Storage){
var beautify = require('js-beautify').js_beautify,
fs = require('fs'),
path = require('path');
var walk = (dir, callback) => {
var results = [];
fs.readdir(dir, (err, list) => {
if (err) {
return callback(err);
}
// AppRegistry.cs
using System;
using Microsoft.Win32;
namespace fountain_writer
{
/// <summary>
/// Registry helper class
/// </summary>
public class AppRegistry
/**
* @return base64 url of an image
*/
export function pickImage(options: ImagePickerOptions = {}): Promise<string> {
interface ImagePath {
name: string;
dir: string;
path: string;
};