Просто мои записки и не более того, как раньше говорил апач "Move along, nothing to see here ;)"
Search This Blog
Tuesday, May 13, 2014
Tuesday, January 21, 2014
A little note about ALSA and x220i thinkpad
First of all you need to find out sound cards indexes.
#> cat /proc/asound/cards
0 [PCH]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xf2520000 irq 42
29 [ThinkPadEC]: ThinkPad EC - ThinkPad Console Audio Control
ThinkPad Console Audio Control at EC reg 0x30, fw unknown
so HDA Intel PCH has index 0
#> /etc/asound.conf
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
cat /etc/modprobe.d/alsa-base
options snd-hda-intel model=laptop index=0
options snd-hda-intel model=thinkpad
Monday, January 20, 2014
Remote reset or reboot Yealink T20\T22
Just send HTTP POST to:
http://192.168.1.2/cgi-bin/ConfigManApp.com (192.168.1.2 - phone address)
with header for basic auth:
'Authorization: Basic KJDSGHj54KLDSJ3='
and content:
PAGEID=7&CONFIG_DATA=RESETFACTORY - for reset
PAGEID=7&CONFIG_DATA=REBOOT - for reboot
Python example
#> python
import urllib2
post = urllib2.Request('http://192.168.1.2/cgi-bin/ConfigManApp.com?Id=7')
post.add_header('Authorization','Basic KJDSGHj54KLDSJ3=')
response = urllib2.urlopen(post, 'PAGEID=7&CONFIG_DATA=RESETFACTORY')
response.msg.lower() == 'ok'
response.code == 200
response.read()
>>> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html><body><script type="text/javascript">if(parent && parent.onloadIFrame)\n parent.onloadIFrame("Talking");\nelse\n window.location.replace(\'/cgi-bin/ConfigManApp.com?Id=13\');\n</script></body></html>'
>>> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html><body><script type="text/javascript">if(parent && parent.onloadIFrame)\n parent.onloadIFrame("RESETFACTORY");\nelse\n window.location.replace(\'/cgi-bin/ConfigManApp.com?Id=13\');\n</script></body></html>'
Tuesday, November 12, 2013
Friday, October 25, 2013
Snake's magic
Simple example:
!#/usr/bin/env python
x = 'abcdef'
if x.find('z'):
print 'True'
else:
print 'False'
What result will you get after run this python code ? False ?, are you sure ?
Wednesday, July 17, 2013
Linux CentOS 6 KVM hot add device
First of all, you should avoid using virsh attach-disk with its limited amount of options. Instead, I suggest to specify the exact disk format you prefer in a separate, temporary XML file, like this:
Before adding it, make sure the hotplug kernel modules are loaded in the guest:
Some distributions, including recent CentOS/RHEL/Fedora have this built-in in the kernel. In this case, check for CONFIG_HOTPLUG_PCI_ACPI. If it's y, then you're all set.
Finally, add it to the running VM using
(optionally, add the --persistent option to let Libvirt update the domain XML definition 'persistent'.)
In the guest, the kernel should now be triggered, as can be checked with dmesg:
[ 321.946440] virtio-pci 0000:00:06.0: using default PCI settings
[...]
[ 321.952782] vdb: vdb1 vdb2
This also works perfectly using the GUI-enabled virt-manager application.
source
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/home/gert/kvm/testdomain-vdb.img'/>
<target dev='vdb' bus='virtio'/>
</disk>Before adding it, make sure the hotplug kernel modules are loaded in the guest:
modprobe acpiphp
modprobe pci_hotplugSome distributions, including recent CentOS/RHEL/Fedora have this built-in in the kernel. In this case, check for CONFIG_HOTPLUG_PCI_ACPI. If it's y, then you're all set.
Finally, add it to the running VM using
virsh # attach-device [domain] /path/to/disk.xml(optionally, add the --persistent option to let Libvirt update the domain XML definition 'persistent'.)
In the guest, the kernel should now be triggered, as can be checked with dmesg:
[ 321.946440] virtio-pci 0000:00:06.0: using default PCI settings
[...]
[ 321.952782] vdb: vdb1 vdb2
This also works perfectly using the GUI-enabled virt-manager application.
source
How to clear memory (caches) on Linux
Since 2.6.16 you need only echo to clear cached memory on Linux box.
This will clear all cached memory.
You can clear only part of it by using 1 or 2. All options:
This will clear all cached memory.
echo 3 > /proc/sys/vm/drop_caches |
- 1 to clear cached pages.
- 2 to clear dentries and inodes.
- 3 to clear all cached memory.
Subscribe to:
Posts (Atom)
