Skip to content

Instantly share code, notes, and snippets.

View ochko's full-sized avatar
🏠
Working from home

Ochko ochko

🏠
Working from home
View GitHub Profile
#!/bin/sh
curlget() {
url=http://ftp5.usa.openbsd.org/pub/OpenBSD/$1/i386
echo $2
curl -O -# $url/$2
}
download() {
# 5.6 -> 56
@ochko
ochko / arel.rb
Last active April 6, 2022 18:39 — forked from janko/arel.rb
Insert statement in Arel
def insert_sql_for(table_name, data)
stmt = Arel::Nodes::InsertStatement.new
stmt.relation = Arel::Table.new(table_name)
stmt.columns = data.keys.map { |k| Arel::Table.new(table_name)[k] }
stmt.values = Arel::Nodes::Values.new(data.values, stmt.columns)
stmt.to_sql
end
require "active_record"
ActiveRecord::Base.establish_connection("postgres:///db")
@ochko
ochko / emacs-copy-clipboard.el
Created October 20, 2011 11:52
It saves last item in emacs kill ring into clipboard
(defun copy-clipboard()
"Save last item in kill ring to clipboard"
(interactive)
(let ((tmp-file (make-temp-file "pbcopy")))
(with-temp-buffer
(yank)
(when (file-writable-p tmp-file)
(write-region (point-min)
(point-max)
tmp-file)
def factorial_zeros_count(x):
res = 0
div = 5
while(x >= div):
res += x / div
div *= 5
return res
n = int(input())
for i in range(n):