Skip to content

Instantly share code, notes, and snippets.

View djphoenix's full-sized avatar
💭
Hex, Bugs & Source Control

Yury Popov djphoenix

💭
Hex, Bugs & Source Control
View GitHub Profile
import time
import torch
import mlx.core as mx
import mlx.nn as mn
import numpy as np
# 1. Generate input
T, B, C = 128, 64, 32
t = T // 2 - 4
@djphoenix
djphoenix / server.js
Last active August 29, 2015 14:08
Node.JS static files host
var mime = require('mime'), fs = require('fs'), url = require('url'), zlib = require('zlib');
module.exports = function(req, res){
var fn = url.parse(req.url).pathname;
if (fn.substr(-1) == '/') fn += 'index.html';
var file = __dirname + '/static' + fn;
try {
var ct = mime.lookup(file);
if (ct.split('/')[0] == 'text') ct += '; charset=UTF-8';
var stat = fs.statSync(file),
gzip = (('accept-encoding' in req.headers) && (req.headers['accept-encoding'].split(',').map(function(e){return e.trim();}).indexOf('gzip') != -1)),