Skip to content

Instantly share code, notes, and snippets.

View painkkiller's full-sized avatar
🎯
Focusing

Dmitry painkkiller

🎯
Focusing
View GitHub Profile
const express = require('express');
const app = express();
app.post('/file', (req, res, next) => {
let first = true;
req.on('data', chunk => {
if (!first) {
return;
@amaranter
amaranter / MerkleTree.js
Created August 13, 2017 21:51
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;
@joepie91
joepie91 / promises-faq.md
Last active June 25, 2023 09:02
The Promises FAQ - addressing the most common questions and misconceptions about Promises.
@markerikson
markerikson / nodeenvDiscussion.md
Last active January 9, 2023 15:24
Summary of process.env.NODE_ENV and its use with Webpack

[02:06 PM] acemarke: @Steven : a couple other thoughts on the whole NODE_ENV thing. First, per my comments, it really is a Node concept. It's a system environment variable that Node exposes to your application, and apparently the Express web server library popularized using its value to determine whether to do optimizations or not
[02:08 PM] acemarke: Second, because of its use within the Node ecosystem, web-focused libraries also started using it to determine whether to they were being run in a "development" environment vs a "production" environment, with corresponding optimizations. For example, React uses that as the equivalent of a C #ifdef to act as conditional checking for debug logging and perf tracking. If process.env.NODE_ENV is set to "production", all those if clauses will evaluate to false.
Third, in conjunction with a tool like UglifyJS that does minification and removal of dead code blocks, a clause that is surrounded with if(process.env.NODE_ENV !== "development")

@k0t0vich
k0t0vich / MobileAndroid-app.template.xml
Last active May 13, 2016 15:15
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>

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!

@mjackson
mjackson / app.js
Created December 29, 2015 05:07
Using webpack with pixi.js
var PIXI = require('pixi.js')
console.log(PIXI)
@mick001
mick001 / logistic_regression.R
Last active June 14, 2024 07:59
Logistic regression tutorial code. Full article available at http://datascienceplus.com/perform-logistic-regression-in-r/
# Load the raw training data and replace missing values with NA
training.data.raw <- read.csv('train.csv',header=T,na.strings=c(""))
# Output the number of missing values for each column
sapply(training.data.raw,function(x) sum(is.na(x)))
# Quick check for how many different values for each feature
sapply(training.data.raw, function(x) length(unique(x)))
# A visual way to check for missing data
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
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