Skip to content

Instantly share code, notes, and snippets.

View ffcv_imagenet_loaders_single_gpu.py
BATCH_SIZE = args.batch_size
NUM_WORKERS = 4
MEAN = torch.tensor([0.485, 0.456, 0.406]) * 255
STD = torch.tensor([0.229, 0.224, 0.225]) * 255
train_pipeline = [
RandomResizedCropRGBImageDecoder((224, 224)),
RandomHorizontalFlip(),
ToTensor(),
ToDevice('cuda:0', non_blocking=True),
View simple_tfjs.js
const model = tf.sequential();
model.add(tf.layers.dense({ units: 5, activation: 'sigmoid', inputShape: [1]}));
model.add(tf.layers.dense({ units: 1, activation: 'sigmoid'}));
model.compile({loss: 'meanSquaredError', optimizer: 'adadelta'});
const xs = tf.tensor1d([1, 2, 3, 4, 5, 6, 7, 8, 9]);
const ys = tf.tensor1d([0, 0, 0, 0, 0, 1, 1, 1, 1]);
model.fit(xs, ys, {epochs: 1000}).then(h => {
console.log("Loss after Epoch " + " : " + h.history.loss[0]);
model.predict(xs).print();
});
View simple_net_keras.py
import keras
import numpy as np
model = keras.Sequential()
model.add(keras.layers.Dense(5, activation='sigmoid', input_shape=(1,)))
model.add(keras.layers.Dense(1, activation='sigmoid'))
model.compile('adadelta', 'mse', metrics=['accuracy'])
xs = np.array(range(1, 10))
ys = np.array([[0] for _ in range(5)] + [[1] for _ in range(4)])
View nginx.config
upstream puma {
server unix:///home/ct_cyrill/apps/sendit/tmp/sockets/puma.sock;
}
server {
listen 80 default_server deferred;
server_name localhost;
root /home/ct_cyrill/apps/sendit/public;
access_log /home/ct_cyrill/apps/sendit/log/nginx.access.log;
View justify-succinct.rb
def justify(text, width)
text.split.reduce([[]]) do |lines, word|
line = lines.last
if (spaces = width - line.join(' ').length) > word.length
line << word
else
spaces.times { |i| line[i % (line.count - 1)] += ' ' } if line.count > 1
lines << [word]
end
lines
View justify.rb
def justify(text, width)
words = text.split
rows = split_rows(words, width)
last_row = rows.pop
text = rows.map{|row| justified_row(row, width)}.join("\n")
[text, last_row.join(" ")].join("\n")
end
def justified_row(row, width)
return row.join if row.length < 2
View vpn.sh
#!/bin/sh
#
# Script for automatic setup of an IPsec/L2TP VPN server on Ubuntu LTS and Debian 8.
# Works on dedicated servers and any KVM- or Xen-based Virtual Private Server (VPS).
#
# DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! THIS IS MEANT TO BE RUN
# ON YOUR DEDICATED SERVER OR VPS!
#
# Copyright (C) 2014-2016 Lin Song
# Based on the work of Thomas Sarlandie (Copyright 2012)
View secret_santa.rb
require "mail"
PEOPLE = JSON.parse File.read("people")
# MAILER_SETUP =
Mail.defaults do
delivery_method :smtp, {
address: "smtp.yandex.ru",
port: 465,
user_name: "kirill@fedyanin.me",
View review.md

address_hints.js.coffee

вот это street = if suggestion.data.street_with_type then suggestion.data.street_with_type else '' можно заменить на это street = '' if !suggestion.data.street_with_type

вот это можно переформатить в одну-две строки, использую filter и join

View npm installation result
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6711 100 6711 0 0 6296 0 0:00:01 0:00:01 --:--:-- 6296
tar=/bin/tar
version:
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.