Skip to content

Instantly share code, notes, and snippets.

import {
IGeneratorClass, currentDir, UpperCamelCase, lowerCamelCase, trimLines,
findGenTemplatesRoot
} from 'gen-templates';
import {relative} from 'path';
export default class Component implements IGeneratorClass {
help(){
return `
Creates something good
`;
let packer: any;
let ts: any;
let autocss: any;
let autoprefixer: any;
let cssmin: any;
let jsmin: any;
let scss: any;
let cssmodules: any;
let grab: any;
let less: any;
function isWhiteSpace(cp) {
return (cp === 0x20) || (cp === 0x09) || (cp === 0x0B) || (cp === 0x0C) || (cp === 0xA0) ||
(cp >= 0x1680 && [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(cp) >= 0);
}
function isLineTerminator(cp) {
return (cp === 0x0A) || (cp === 0x0D) || (cp === 0x2028) || (cp === 0x2029);
}
// const globMap = new Uint8Array(256 * 256);
@cevek
cevek / index.js
Last active October 19, 2016 07:40
const esprima = require('esprima');
const recast = require('recast');
const fs = require('fs');
var acorn = require("acorn");
var escodegen = require("escodegen");
var babylon = require("babylon");
var cst = require("cst");
var browserify = require('browserify');
var b = browserify();
function abc(fn, iter, arg) {
var name = getName(fn);
console.time(name);
for (var i = 0; i < iter; i++) {
fn(arg);
}
console.timeEnd(name);
}
function getName(fn) {
@cevek
cevek / objvsarr.js
Last active November 27, 2016 10:53
BinarySearch vs ArrayFullSearch vs HashSearch
//results for 10 items array/hash
// 3,6,8,10ms/1m - binary search
// 15ms/1m - array fullscan
// 10ms/1m - hash fullscan
// 2ms/1m - hash found
function abc(fn, title, count, arg, arg2) {
console.time(title);
var result;
var i = count;
function Utf8BufferToUint16Array(buff) {
let c, char2, char3;
let len = buff.length;
let i = 0;
let ni = 0;
const newA = new Uint16Array(len);
while (i < len) {
c = buff[i++];
if (c < 128) {
@cevek
cevek / pak.js
Created November 16, 2016 10:47
pak file format read/write
"use strict";
const fs = require('fs');
console.log(process.argv);
const version = 4;
const file = process.argv[2];
const data = fs.readFileSync(file);
interface RouteProps {
search: {};
urlParams: {};
}
interface Data{
a: number;
}
interface AppProps extends RouteProps {
//results
//1000 massive nodes with 32 subnodes, a lot of attributes
//deepclone: 50ms
//createFromJSOjb: 150ms
function createNodes() {
var div = document.createElement('div');
div.innerHTML = '<div class=" thing id-t3_5fwc30 odd gilded link " id="thing_t3_5fwc30" data-fullname="t3_5fwc30" data-type="link" data-author="Hawke45" data-author-fullname="t2_bnjaz" data-subreddit="pics" data-subreddit-fullname="t5_2qh0u" data-timestamp="1480595816000" data-url="https://i.reddituploads.com/b45b1452a8414f38a0b498007e5bcd3f?fit=max&amp;h=1536&amp;w=1536&amp;s=cd98d1163f90c23f1f5ec11083507bb8" data-domain="i.reddituploads.com" data-rank="1" data-context="listing">' +
'<p class="parent"></p><span class="rank">1</span><div class="midcol unvoted"><div class="arrow up login-required access-required" data-event-action="upvote" role="button" aria-label="Голосовать «за»" tabindex="0"></div><div class="score dislikes">10391</div><div class="score unvoted">10392</div><div class="score likes">10393</div><div c