Skip to content

Instantly share code, notes, and snippets.

View painkkiller's full-sized avatar
🎯
Focusing

Dmitry painkkiller

🎯
Focusing
View GitHub Profile
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Dropzone from 'react-dropzone';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import styles from './FileUploader.styl';
import FileIcon from '../../FileIcon/index';
import {
uploadAttachments,
const express = require('express');
const app = express();
app.post('/file', (req, res, next) => {
let first = true;
req.on('data', chunk => {
if (!first) {
return;
@painkkiller
painkkiller / AllUnderscoreMethods.js
Created June 19, 2018 15:35 — forked from alexhawkins/AllUnderscoreMethods.js
Basic Implementation of 'most' Underscore Methods from Scratch
var _ = {};
/*********IDENTITY**********/
_.identity = function(val) {
return val;
};
/*********FIRST**********/
_.first = function(array, n) {
@painkkiller
painkkiller / gist:bd4c22a8681d885c5123a3129af407ab
Created May 11, 2018 10:14 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@painkkiller
painkkiller / event.js
Created April 16, 2018 10:11 — forked from wildlyinaccurate/event.js
Really simple Javascript custom event system
var Event = function() {
var self = this;
self.queue = {};
self.fired = [];
return {
fire: function(event) {
@painkkiller
painkkiller / MerkleTree.js
Created April 14, 2018 21:03 — forked from amaranter/MerkleTree.js
Merkle Tree Implementation with Javascript and CryptoJS (SHA-256)
/**
* MerkleTree Implementation
* @version 1.0.0
* @author Ronny Amarante <me@amaranter.com>
*/
var SHA256 = require("crypto-js/sha256");
function MerkleTree(transactions) {
this.transactions = transactions;
@painkkiller
painkkiller / ReplicatedRandomChrome.js
Created March 21, 2018 13:31 — forked from fta2012/ReplicatedRandomChrome.js
EDIT: This code no longer works on chrome but still works for legacy versions of node. Updated code moved to https://github.com/fta2012/ReplicatedRandom/tree/master/node.
var rngstate;
function MathRandom() {
// Our own implementation of Math.random().
// Source code was copied from https://github.com/v8/v8/blob/4.6.85/src/math.js#L131
// You need to initialize rngstate with `solve` before this can be used.
// If using node.js, you have to s/18030/18273/g here and in `solve` since they implement it slightly differently: https://github.com/nodejs/node-v0.x-archive/blob/d13d7f74d794340ac5e126cfb4ce507fe0f803d5/deps/v8/src/math.js#L146
console.assert(rngstate, "You need to set the global variable `rngstate` first. For example: `rngstate = solve(Math.random(), Math.random());`");
if (!rngstate) return;
var r0 = (Math.imul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
rngstate[0] = r0;
@painkkiller
painkkiller / app.js
Created November 18, 2016 16:43 — forked from mjackson/app.js
Using webpack with pixi.js
var PIXI = require('pixi.js')
console.log(PIXI)
@painkkiller
painkkiller / MobileAndroid-app.template.xml
Created April 13, 2016 07:42 — forked from k0t0vich/MobileAndroid-app.template.xml
air android ant make apk for armv7 and x86
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/[airVersionPattern]">
<filename>[fileNamePattern]</filename>
<id>[packagePattern]</id>
<name>[namePattern]</name>
<versionNumber>[versionNumberPattern]</versionNumber>
<versionLabel>[versionLabelPattern]</versionLabel>
<initialWindow>
<content>[This value will be overwritten by Flash Builder in the output app.xml]</content>
@painkkiller
painkkiller / gist:190650ed6686980d41c6
Created January 15, 2016 20:43 — forked from Nutrox/gist:778619
AS3 - Isometric matrix transformation.
const DEGRAD:Number = Math.PI / 180;
var iso:Matrix = new Matrix();
iso.rotate( -45 * DEGRAD ); // rotate anti-clockwise by 45 degrees
iso.scale( 1.0, 0.5 ); // scale vertically by 50%
iso.translate( 100, 100 ); // set position if needed
displayObject.transform.matrix = iso;