Tools
Записки программиста, обо всем и ни о чем. Но, наверное, больше профессионального.
2014-07-31
Large-Scale Machine Learning & Example
Posted by
Valentin
at
11:30
0
comments
2014-07-30
Open Source vs Proprietary
Posted by
Valentin
at
11:30
0
comments
Labels: opensource
2014-07-29
webcamfixer
Posted by
Valentin
at
11:30
0
comments
Labels: python
2014-07-28
Import VirtualBox machine
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX3" PortCount="2" useHostIOCache="true">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{c8c7052e-926c-4419-93ac-46756167604f}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" port="0" device="1">
<Image uuid="{c8c7052e-926c-4419-93ac-46756167604f}"/>
</AttachedDevice>
<AttachedDevice passthrough="false" type="DVD" port="1" device="0"/>
</StorageController>
<StorageController name="Floppy Controller" type="I82078" PortCount="1" useHostIOCache="true">
<AttachedDevice type="Floppy" port="0" device="0"/>
</StorageController>
</StorageControllers>
|
<DiskSection>
<Info>List of the virtual disks used in the package</Info>
<Disk ovf:capacity="10737418240" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" vbox:uuid="2d8c0bbc-ed2a-424a-9cfa-e8e922eb42ac"/>
<Disk ovf:capacity="107374182400" ovf:diskId="vmdisk2" ovf:fileRef="file2" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" vbox:uuid="c8c7052e-926c-4419-93ac-46756167604f"/>
</DiskSection>
|
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX3" PortCount="2" useHostIOCache="true">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{c8c7052e-926c-4419-93ac-46756167604f}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" port="0" device="1">
<Image uuid="{2d8c0bbc-ed2a-424a-9cfa-e8e922eb42ac}"/>
</AttachedDevice>
<AttachedDevice passthrough="false" type="DVD" port="1" device="0"/>
</StorageController>
<StorageController name="Floppy Controller" type="I82078" PortCount="1" useHostIOCache="true">
<AttachedDevice type="Floppy" port="0" device="0"/>
</StorageController>
</StorageControllers>
|
Posted by
Valentin
at
11:30
0
comments
2014-07-25
NLP
Posted by
Valentin
at
11:30
3
comments
2014-07-24
Duck Jibe
Posted by
Valentin
at
11:30
3
comments
Labels: video, windsurfing
2014-07-23
2.5 тонны
Posted by
Valentin
at
11:30
0
comments
2014-07-22
fb2tools
Posted by
Valentin
at
11:30
0
comments
Labels: python
2014-07-21
10 распространенных ошибок
>>> def foo(bar=[]): # bar is optional and defaults to [] if not specified
... bar.append("baz") # but this line could be problematic, as we'll see...
... return bar
>>> class A(object): ... x = 1 ... >>> class B(A): ... pass ... >>> class C(A): ... pass ... >>> print A.x, B.x, C.x 1 1 1 >>> B.x = 2 >>> print A.x, B.x, C.x 1 2 1 >>> A.x = 3 >>> print A.x, B.x, C.x 3 2 3
>>> try: ... l = ["a", "b"] ... int(l[2]) ... except ValueError, IndexError: # To catch both exceptions, right? ... pass ... Traceback (most recent call last): File "<stdin>", line 3, in <module> IndexError: list index out of range
>>> try: ... l = ["a", "b"] ... int(l[2]) ... except (ValueError, IndexError) as e: ... pass
>>> x = 10 >>> def foo(): ... x += 1 ... print x ... >>> foo() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in foo UnboundLocalError: local variable 'x' referenced before assignment
>>> numbers = [n for n in range(10)]
>>> for i in range(len(numbers)):
... if odd(numbers[i]):
... del numbers[i] # BAD: Deleting item from a list while iterating over it
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
IndexError: list index out of range
>>> def create_multipliers(): ... return [lambda x : i * x for i in range(5)] >>> for multiplier in create_multipliers(): ... print multiplier(2) ... You might expect the following output: 0 2 4 6 8 But you actually get: 8 8 8 8 8
# In a.py:
import b
def f():
return b.x
print f()
# And in b.py:
import a
x = 1
def g():
print a.f()
import sys
def bar(i):
if i == 1:
raise KeyError(1)
if i == 2:
raise ValueError(2)
def bad():
e = None
try:
bar(int(sys.argv[1]))
except KeyError as e:
print('key error')
except ValueError as e:
print('value error')
print(e)
bad()
UnboundLocalError: local variable 'e' referenced before assignment
import foo
class Bar(object):
...
def __del__(self):
foo.cleanup(self.myhandle)
Posted by
Valentin
at
11:30
0
comments
2014-07-18
The Onion Movie 2008
Posted by
Valentin
at
11:30
0
comments
2014-07-17
Safe way to setup firewall
#!/bin/bash
# disable_fw.sh - Reset (disable) firewall
# ---------------------------------------------------------------------------------------------------------------
# Initially Written by Vivek Gite <vivek@nixcraft.com>
# Rewrited by Valentin Fedulov <vasnake@gmail.com>
# Source: http://www.cyberciti.biz/faq/turn-on-turn-off-firewall-in-linux/
# https://gist.github.com/vasnake/de19b6162ed97b0fd92b
# ---------------------------------------------------------------------------------------------------------------
# You can copy / paste / redistribute this script under GPL version 2.0 or above
# =============================================================
# set to true if it is CentOS / RHEL / Fedora box
RHEL=false
### no need to edit below ###
IPT=/sbin/iptables
IPT6=/sbin/ip6tables
main() {
if [ "$RHEL" == "true" ];
then
# reset firewall using redhat script
/etc/init.d/iptables stop
/etc/init.d/ip6tables stop
else
# for all other Linux distro use following rules to reset firewall
reset_iptables ${IPT} "/proc/net/ip_tables_names"
reset_iptables ${IPT6} "/proc/net/ip6_tables_names"
fi
}
reset_iptables() {
local ipt_bin="${1}"
local tables="${2}"
$ipt_bin -P INPUT ACCEPT
$ipt_bin -P OUTPUT ACCEPT
$ipt_bin -P FORWARD ACCEPT
$ipt_bin -F
$ipt_bin -X
$ipt_bin -Z
for table in $(<$tables)
do
$ipt_bin -t $table -F
$ipt_bin -t $table -X
$ipt_bin -t $table -Z
done
}
main
|
chmod +x /root/disable_fw.sh nano /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ */5 * * * * root /root/disable_fw.sh |
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
watch -d "iptables -L --line-numbers -nv"
/etc/sysconfig/iptables *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -m recent --update --seconds 15 -j DROP -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -m recent --set -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT |
/etc/sysconfig/ip6tables *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p ipv6-icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -m recent --update --seconds 15 -j DROP -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -m recent --set -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A INPUT -j REJECT --reject-with icmp6-adm-prohibited -A FORWARD -j REJECT --reject-with icmp6-adm-prohibited COMMIT |
iptables-restore < /root/working.iptables.rules
iptables-save > /root/working.iptables.rules
chkconfig iptables off chkconfig iptables on
system-config-firewall-tui
Posted by
Valentin
at
11:30
0
comments
2014-07-16
PEP 20
http://docs.python-guide.org/en/latest/writing/style/
http://artifex.org/~hblanks/talks/2011/pep20_by_example.html
Posted by
Valentin
at
11:30
0
comments
Labels: python
2014-07-15
Фантомы / Shutter 2008
Posted by
Valentin
at
11:30
0
comments
2014-07-14
Logging ProjectMate
Posted by
Valentin
at
11:30
0
comments
2014-07-11
Recommender Systems
Если же у фильма нет еще ни одной оценки, лучше убрать этот фильм из расчетов.
Posted by
Valentin
at
11:30
0
comments
Архив блога
-
▼
2014
(267)
-
▼
июля
(23)
- Large-Scale Machine Learning & Example
- Open Source vs Proprietary
- webcamfixer
- Import VirtualBox machine
- NLP
- Duck Jibe
- 2.5 тонны
- fb2tools
- 10 распространенных ошибок
- The Onion Movie 2008
- Safe way to setup firewall
- PEP 20
- Фантомы / Shutter 2008
- Logging ProjectMate
- Recommender Systems
- Anomaly Detection, Recommender Systems
- Автошкола-онлайн
- subprocess.Popen
- Автошкола-онлайн
- Pumping
- Водный старт в петлях
- -fno-delete-null-pointer-checks
- Еще про Автошколу-онлайн
-
▼
июля
(23)











































