Skip to content

Instantly share code, notes, and snippets.

View linuxenko's full-sized avatar

Svetlana Linuxenko linuxenko

View GitHub Profile
var DEFAULT_MAX_LISTENERS = 12
function error(message, ...args){
console.error.apply(console, [message].concat(args))
console.trace()
}
class EventEmitter {
constructor(){
this._maxListeners = DEFAULT_MAX_LISTENERS
@linuxenko
linuxenko / index.js
Created February 19, 2016 13:40 — forked from bnerd/index.js
Serve large files with Node.js
var libpath = require('path');
var http = require('http');
var fs = require('fs');
var url = require('url');
var bind_port = 8001;
var path = "/path/to/your/base_directory/";
http.createServer(function (request, response) {
var uri = url.parse(request.url).pathname;
var filename = libpath.join(path, uri);
@linuxenko
linuxenko / server.js
Created April 2, 2016 06:52 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@linuxenko
linuxenko / .eslintrc.js
Created April 26, 2016 19:49 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@linuxenko
linuxenko / easing.js
Created September 21, 2016 17:14 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@linuxenko
linuxenko / app.js
Created October 5, 2016 14:52 — forked from madbence/app.js
const net = require('net');
const exec = require('child_process').exec;
const os = require('os');
function run(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (err, stdout) => {
if (err) {
return reject(err);
}
@linuxenko
linuxenko / README.md
Created October 31, 2016 20:19 — forked from joyrexus/README.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@linuxenko
linuxenko / web-servers.md
Created November 1, 2016 14:21 — forked from neilhwatson/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@linuxenko
linuxenko / nanopng.cpp
Created November 19, 2016 08:44 — forked from fpsunflower/nanopng.cpp
Tiny PNG output
// c++ -o nanopng nanopng.cpp && ./nanopng /tmp/foo.png
#include <cstdio>
// write an uncompressed PNG file from a uint8 RGB buffer
struct Png {
FILE*f; unsigned int tab[256], crc; ~Png() { fclose(f); }
Png(const char* fn, int w, int h, const unsigned char* c) {
crc=0x575e51f5;unsigned char d[]={137,80,78,71,13,
10,26,10,0,0,0,13,73,72,68,82,73,68,65,84,120,1,0,
0,0,73,69,78,68,174,66,96,130};/*chunk headers*/
@linuxenko
linuxenko / encoder.js
Created November 19, 2016 10:01 — forked from mscdex/encoder.js
Encode text into a PNG
const kCRCTable = new Int32Array([
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,