Skip to content

Instantly share code, notes, and snippets.

@tokhi
tokhi / unixToolbox.md
Last active December 17, 2023 20:43
Collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users.

#Unix Toolbox

This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.

##Unix Toolbox revision 14.4

The latest version of this document can be found at http://cb.vu/unixtoolbox.xhtml. Replace .xhtml on the link with .pdf for the PDF version and with .book.pdf for the booklet version. On a duplex printer the booklet will create a small book ready to bind. This XHTML page can be converted into a nice PDF document with a CSS3 compliant application (see the script example). See also the about page.
Error reports and comments are m
@tokhi
tokhi / buergerbot.rb
Last active November 25, 2023 12:01 — forked from pbock/buergerbot.rb
Bürgerbot: Refreshes the Berlin Bürgeramt page until an appointment becomes available, then notifies you.
#!/usr/bin/env ruby
# make sure you the watir gem installed -> gem install watir
require 'watir'
def log (message) puts " #{message}" end
def success (message) puts "+ #{message}" end
def fail (message) puts "- #{message}" end
def notify (message)
success message.upcase
system 'osascript -e \'Display notification Burgerbot with title "%s"\'' % message
rescue StandardError => e
@tokhi
tokhi / go_tutorial.md
Last active July 3, 2023 15:33
Go Tutorial

Go Tutorial

Function Types

Function type is useful:

  • In the case of higher-order functions as we have seen in the above example. The argument and return type is specified using function type
  • In the case of defining interfaces in go as in the interface, only the function type is specified. Whatever implements this interface has to define a function of the same type

Notice that the interface shape only defines the type of function

@tokhi
tokhi / spread.rb
Last active January 7, 2022 19:22
Stock spread option maximum loss and profit calculation
def break_even(long_sp, short_sp, ndp)
if long_sp > short_sp # bear option
long_sp - ndp
else # bull option
long_sp + ndp
end
end
def max_profit(long_sp, short_sp, ndp)
if(long_sp > short_sp) # bear option
@tokhi
tokhi / rails.sh
Last active August 11, 2020 09:59
Some useful rails command
# adding a column to an existing table
rails g migration AddNameToUsers name:string
# or
rails generate migration add_image_to_pictures image_id:string
# to remove
rails d migration AddNameToUsers name:string
# remove column from model
rails g migration RemoveProjectIDFromProjects project_id:string
@tokhi
tokhi / aseman_range_to_abi.md
Last active January 26, 2019 21:56
آسمان رنگ تو آبی آبی

آسمان رنگ تو آبی آبی

آسمان دریای پر ز آبی

چه بگویم ز ستاره گانت

که خودت کشور آفتابی

آسمان عاشق مهتابی تو و

@tokhi
tokhi / leads.json
Last active December 18, 2018 17:24
leads.json
[
{
"lead": {
"id": 299888,
"trade_id": 6,
"details": {
"project_deadline": "So schnell wie möglich"
},
"closed_at": null,
"expiration_date": "2018-12-13T01:22:19.000+01:00",
@tokhi
tokhi / postgres.md
Last active December 17, 2017 23:18
postgresql commands

Some useful postgresql commands

#  start postgresql
/usr/lib/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.1/boom/ -c config_file=/etc/postgresql-9.0/postgresql.conf

#
# #psql dump:
pg_dump #host localhost #port 5555 #username "foo" #format tar #blobs #verbose #file "/home/tokhi/Documents/Castaclip/castaclip.master.130612.tmp" "verticals"
# # restore:
@tokhi
tokhi / iterm2-solarized.md
Created February 28, 2017 11:41 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@tokhi
tokhi / ElasticSearch.md
Last active January 6, 2017 00:44
Elastic Search in simple words

Elastic Search

Elasticsearch is a real time search engine where a change to an index will be propegated to the whole cluster within a second.

An elasticsearch cluster indicated as one or more nodes, collection of nodes containing all the data, default cluster name is elasticserach.

A node is a single server and part of a cluster, node participate in searching and indexing.

Index is collection of documents equavalent to a database within a relational system, index name must be lowercase Type is represetn a class = table