Tuesday, October 22, 2013

Shell comand

`cd -` -  toggle between current and last folder
`sudo !!` - run previous command with `sudo`
` <comand>` - without saving to history (space before comand)
`>file.txt` - create new or clean old file
`^foo^bar` - replace in previous command `foo` to `bar`


Saturday, September 7, 2013

Interest browser link (like home page)


Just copy and paste to your browser.

data:text/html,%20<style>html,body{margin:%200;%20padding:%200;}</style><textarea%20style="font-size:%201.5em;%20line-height:%201.5em;%20background:%20%23000;%20color:%20%233a3;%20width:%20100%;%20height:%20100%;%20border:%20none;%20outline:%20none;%20margin:%200;%20padding:%2090px;"%20autofocus%20placeholder="wake%20up%20Neo..."%20/>

Few GIT alias

[alias]
lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
report = "log --author=Marco --since='2 sunday ago' --until='1 sunday ago' --format='%Cgreen%ci%Creset %s%Creset' --no-merges"

report-csv = "log --author=Marco --since='2 sunday ago' --until='1 sunday ago' --format='\"%ci\",\"%s\"' --no-merges"

today = "log --since=midnight --author='Your Initial' --oneline"

Like sort by multiple items

array.sort_by do |item|
  [item.a, item.b]
end

Saturday, August 3, 2013

Little bit color

 0 #000000  1 #800000  2 #008000  3 #808000  4 #000080  5 #800080  6 #008080
 8 #808080  9 #ff0000 10 #00ff00 11 #ffff00 12 #0000ff 13 #ff00ff 14 #00ffff

 16 #000000  17 #00005f  18 #000087  19 #0000af  20 #0000d7  21 #0000ff
 22 #005f00  23 #005f5f  24 #005f87  25 #005faf  26 #005fd7  27 #005fff
 28 #008700  29 #00875f  30 #008787  31 #0087af  32 #0087d7  33 #0087ff
 34 #00af00  35 #00af5f  36 #00af87  37 #00afaf  38 #00afd7  39 #00afff
 40 #00d700  41 #00d75f  42 #00d787  43 #00d7af  44 #00d7d7  45 #00d7ff
 46 #00ff00  47 #00ff5f  48 #00ff87  49 #00ffaf  50 #00ffd7  51 #00ffff

Saturday, July 27, 2013

Useful keys for - Console, Tmux

CONSOLE

CmdAction
aon the beginning
udelete all line
wdelete previous word
xxselect line
iinsert tab
e

edit line

hlike backspace
jlike enter
kdelete to the end
lclear screen and live line comnand

b

move right
f

move left

rsearch in history

TMUX

tmux new -s session-name
tmux attach-session -t shared-session

Ctrl+b+:
CmdAction
wList window
sList sessions
cCreate a new window
xClose widnow
nChange to next window
pChange to previous window
"Split pane horizontally
%Split pane vertically
,Rename current window
oMove to next pane
dDeatach session
[Start read mod

Monday, July 1, 2013

Array

var = Array(1) # => [1]
var = *1       # => [1]

# * is the same as Array

var = Array([1,2,3]) #=> [1,2,3]
var = *[1,2,3]       #=> [1,2,3]

# its useful when we need array like
var = [var] unless var.is_a? Array
var = [var].flatten

# we can write
var = *var     # => [var]
# but can't
*var           # => syntax error

Sunday, June 30, 2013

Ruby Include and Extend

module Base
  def print
    p 'base'
  end
end

class A
  # add method for instance
  include Base
end

A.new.print


class B
  # add method for class
  extend Base
end

B.print

class C
  # include module for singleton
  # the same like extend
  class << self
    include Base
  end
end

C.print
include work the same as inheritance but its not the same:
  1. class have only one parent
  2. include extend only instance
# check include
A.new.kind_of? Base #=> true

# check extend
B.kind_of? Base #=> true



Saturday, June 29, 2013

Highlighting code

<!-- Syntax Highlighter Additions START -->

<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" />

<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeEmacs.css" rel="stylesheet" type="text/css" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript" />



<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript" />

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript" />

 

<script language="javascript" type="text/javascript">

 SyntaxHighlighter.config.bloggerMode = true;

 SyntaxHighlighter.all();

</script>

<!-- Syntax Highlighter Additions END -->
In post we write something like that:
<pre class="brush:ruby">
... code
</pre>

Vim




Ruby singleton

# All is Object
# =============
#
# print - is singleton method for instance

instance = Document.new
def instance.print
end

class << instance
  def print; end
end

# print - is singleton method for Document
# Document - is instance too of Class object

def Document.pring
end

class Document
  class << self
    def print; end
  end
end



Ruby class variables

# B class redefine class variable

class A
  @@class_var = 'first'

  def first
    @@class_var
  end
end

class B < A
  @@class_var = 'second'

  def second
    @@class_var
  end
end

p B.new.first           # => second
p B.new.second          # => second
p B.singleton_methods   # => []


# A and B class have different variable
# In this case we have instance(singleton) variable for A and B

class A
  @class_var = 'first'

  class << self
    attr_accessor :class_var
  end

  def first
    A.class_var
  end
end

class B < A
  @class_var = 'second'

  class << self
    attr_accessor :class_var
  end

  def second
    B.class_var
  end
end

p B.new.first           # => first
p B.new.second          # => second
p B.singleton_methods   # => [:class_var, :class_var=]


Sunday, May 19, 2013

I2P hosts


http://inr.i2p/export/alive-hosts.txt
http://i2host.i2p/cgi-bin/i2hostetag
http://stats.i2p/cgi-bin/newhosts.txt
http://tino.i2p/hosts.txt
http://inproxy.tino.i2p/status.php
http://dream.i2p/hosts.txt
http://hosts.i2p/
http://biw5iauxm7cjkakqygod3tq4w6ic4zzz5mtd4c7xdvvz54fyhnwa.b32.i2p/uncensored_hosts.txt
http://trevorreznik.i2p/hosts.txt
http://cipherspace.i2p/addressbook.txt
http://hosts.i2p/hosts.cgi?filter=all
http://bl.i2p/hosts2.txt
http://rus.i2p/hosts.txt
http://www.i2p2.i2p/hosts.txt


I2P:
http://www.i2p2.i2p/ главная страница проекта в сети I2P
http://i2p-projekt.i2p/ зеркало для http://www.i2p2.i2p/
http://i2plugins.i2p/ плагины I2P
http://i2pbote.i2p/ распределённая p2p почта I2P 2010 (плагин)
http://inr.i2p/ про eepsites [ru, en]
http://forum.i2p/ I2P форум
http://forum.rus.i2p/ русский I2P форум [ru]
http://rus.i2p/ русская I2P вики

Wednesday, May 1, 2013

Vagrant

vagrant box add <name> <http or dir to *.box> virtualbox

It appears your machine doesn't support NFS, or there is not an
adapter to enable NFS on this machine for Vagrant. Please verify
that `nfsd` is installed on your machine, and try again. If you're
on Windows, NFS isn't supported. If the problem persists, please
contact Vagrant support.

install nfs
run nfsd

Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory

install virtualbox-host-modules
run modprobe -a vboxnetflt vboxnetadp

vagrant up,  ssh, halt, suspend

Disable blanking screen

Before device section in xorg.conf insert:

Section "ServerFlags"
       Option         "blank time" "0"
       Option         "standby time" "0"
       Option         "suspend time" "0"
       Option         "off time" "0"
EndSection


 
 
Blogger Templates