Skip to content

Instantly share code, notes, and snippets.

View kirill-fedyanin's full-sized avatar

Kirill kirill-fedyanin

View GitHub Profile
@kirill-fedyanin
kirill-fedyanin / gist:6745863
Created September 28, 2013 19:51
Force check_box_tag remember the value
<%= check_box_tag :doc ,"value",!params[:doc].nil? %>
% 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.

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

@kirill-fedyanin
kirill-fedyanin / secret_santa.rb
Created December 22, 2015 20:13
Secret santa
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",
#!/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)
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
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
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;
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)])
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();
});