tag:blogger.com,1999:blog-44433728412407455112024-02-08T12:38:04.125+01:00Talk is cheap. Show me the code.Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.comBlogger65125tag:blogger.com,1999:blog-4443372841240745511.post-56088611089809247172017-06-25T22:02:00.000+02:002017-06-25T23:47:13.391+02:00Site migrated to WordPressSite migrated to <a href="https://viliampucik.wordpress.com/">viliampucik.wordpress.com</a>!Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-61937905269019997462017-06-04T13:52:00.001+02:002017-06-04T13:52:27.982+02:00Disable SSL Certificate Verification in Git<pre>
git config --global http.sslVerify false
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-28598106477174740212017-06-01T01:02:00.000+02:002017-06-01T01:02:21.471+02:00Compressed Disk BackupDisk backup with progress bar using parallel gz compression:
<pre>
pv /dev/sda | pigz > /mnt/backup/disk.gz
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-1137666115430173172017-02-11T17:38:00.001+01:002017-02-12T20:43:42.853+01:00ACPI Errors FixingAn example how to fix the following ACPI errors experienced on some of HP notebooks.
<pre>
$ dmesg | grep 'ACPI Error'
[ 8.397813] ACPI Error: [CFGD] Namespace lookup failure, AE_NOT_FOUND (20160831/psargs-359)
[ 8.398670] ACPI Error: Method parse/execution failed [\_TZ.PSL] (Node ffff88048d0a8d20), AE_NOT_FOUND (20160831/psparse-543)
[ 8.399741] ACPI Error: Method parse/execution failed [\_TZ.GFXZ._PSL] (Node ffff88048d0a8190), AE_NOT_FOUND (20160831/psparse-543)
[ 9.119569] ACPI Error: [CFGD] Namespace lookup failure, AE_NOT_FOUND (20160831/psargs-359)
[ 9.120266] ACPI Error: Method parse/execution failed [\_TZ.PSL] (Node ffff88048d0a8d20), AE_NOT_FOUND (20160831/psparse-543)
[ 9.121184] ACPI Error: Method parse/execution failed [\_TZ.BATZ._PSL] (Node ffff88048d0a8a50), AE_NOT_FOUND (20160831/psparse-543)
</pre>
<ol>
<li>Install <code>iasl</code> package.</li>
<li>Create a directory to which ACPI tables can be extracted and decompiled:
<pre>
mkdir ~/acpi
cd ~/acpi
acpidump > acpidump
acpixtract acpidump
iasl -e ssdt*.dat -d dsdt.dat
</pre>
</li>
<li>Examine DSDT and related SSDT tables if necessary. Observe the hierarchy of the structures to properly locate the problematic code. Noting ACPI names consist of up to four letters and can repeat multiple times among the namespaces. Please see <a href="https://acpica.org/documentation">ACPICA Documentation</a> for more.</li>
<li>In the above mentioned case it turned out that <code>\_TZ.GFXZ._PSL</code> and <code>\_TZ.BATZ._PSL</code> methods call <code>\_TZ.PSL</code> method which fails because of not recognized <code>CFGD</code> object. It seems that the purpose of the last mentioned method is to return number of installed CPU cores. The fix consists of modifying <code>dsdt.dsl</code> file, removing the problematic code and increasing OEM revision.
<p>
Before:
<pre>
DefinitionBlock ("", "DSDT", 2, "HPQOEM", "1909 ", 0x00000001)
...
Method (PSL, 0, Serialized)
{
If ((CFGD & 0x01000000))
{
If ((TCNT == 0x08))
{
Return (Package (0x08)
{
\_PR.CPU0,
\_PR.CPU1,
\_PR.CPU2,
\_PR.CPU3,
\_PR.CPU4,
\_PR.CPU5,
\_PR.CPU6,
\_PR.CPU7
})
}
If ((TCNT == 0x04))
{
Return (Package (0x04)
{
\_PR.CPU0,
\_PR.CPU1,
\_PR.CPU2,
\_PR.CPU3
})
}
Return (Package (0x02)
{
\_PR.CPU0,
\_PR.CPU1
})
}
Else
{
Return (Package (0x01)
{
\_PR.CPU0
})
}
}
</pre>
</p>
<p>
After:
<pre>
DefinitionBlock ("", "DSDT", 2, "HPQOEM", "1909 ", 0x00000002)
...
Method (PSL, 0, Serialized)
{
If ((TCNT == 0x08))
{
Return (Package (0x08)
{
\_PR.CPU0,
\_PR.CPU1,
\_PR.CPU2,
\_PR.CPU3,
\_PR.CPU4,
\_PR.CPU5,
\_PR.CPU6,
\_PR.CPU7
})
}
If ((TCNT == 0x04))
{
Return (Package (0x04)
{
\_PR.CPU0,
\_PR.CPU1,
\_PR.CPU2,
\_PR.CPU3
})
}
Return (Package (0x02)
{
\_PR.CPU0,
\_PR.CPU1
})
}
</pre>
</p>
<p>
Just in case here is the diff:
<script src="https://gist.github.com/viliampucik/c72dd602e820f68ac55f46e72fe18875.js"></script>
</p>
</li>
<li>Compile the file and create CPIO archive from it which will be used as an initial ramdisk to override the original ACPI table during the kernel boot. Please see <a href="https://wiki.archlinux.org/index.php/DSDT">DSDT - ArchWiki</a> and <a href="https://www.kernel.org/doc/Documentation/acpi/initrd_table_override.txt">Upgrading ACPI tables via initrd</a> for more:
<pre>
mkdir -p kernel/firmware/acpi
iasl -tc dsdt.dsl
cp dsdt.aml kernel/firmware/acpi
find kernel | cpio -H newc --create > /boot/acpi_override
</pre>
</li>
<li>Edit the boot loader configuration file to include the ramdisk as one of the first ones. For example in case of Arch Linux GRUB2 modify <code>/boot/grub/grub.cfg</code> file to contain the following section for the active kernel:
<pre>
initrd /boot/intel-ucode.img /boot/acpi_override /boot/initramfs-linux.img
</pre>
</li>
<li>Reboot the system to apply the ACPI fix and verify ACPI table override works and there are no ACPI errors:
<pre>
$ dmesg | grep -e 'ACPI Error' -e 'ACPI: DSDT' -e 'ACPI: Table'
[ 0.000000] ACPI: DSDT ACPI table found in initrd [kernel/firmware/acpi/dsdt.aml][0x23eef]
[ 0.000000] ACPI: Table Upgrade: override [DSDT-HPQOEM-1909 ]
[ 0.000000] ACPI: DSDT 0x000000005EFD1000 Physical table override, new table: 0x000000005DB5B000
[ 0.000000] ACPI: DSDT 0x000000005DB5B000 023EEF (v02 HPQOEM 1909 00000002 INTL 20161117)
</pre>
</li>
</ol>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-90852499636924377092016-12-14T18:12:00.000+01:002016-12-14T18:12:11.038+01:00Vertica User ManagementCreate <i>testuser</i> with read-only access to <i>testtable</i> in <i>testschema</i>.
<pre>
CREATE USER testuser IDENTIFIED BY 'password123';
GRANT USAGE ON SCHEMA testschema TO testuser;
GRANT SELECT ON testschema.testtable TO testuser;
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-49833613636541972572016-09-30T21:54:00.000+02:002016-09-30T21:54:55.858+02:00NetworkManager: Disable Sending Hostname to DHCP ServerEdit <code>/etc/NetworkManager/NetworkManager.conf</code> file to contain the following default settings for new connections:
<pre>
[connection]
ipv4.dhcp-send-hostname=false
ipv6.dhcp-send-hostname=false
</pre>
Disable sending hostname to DHCP server for already existing connections:
<pre>
nmcli -t -f uuid connection | while read uuid; do
nmcli connection modify $uuid \
ipv4.dhcp-send-hostname false \
ipv6.dhcp-send-hostname false
done
</pre>
Restart NetworkManager to apply the settings:
<pre>
systemctl restart NetworkManager
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com2tag:blogger.com,1999:blog-4443372841240745511.post-55578145850009047922016-08-10T09:27:00.000+02:002016-08-10T09:27:08.660+02:00Perl UDP DaemonA simple UDP daemon listening on UDP/162 port.
<script src="https://gist.github.com/viliampucik/133ec80d354e3e1362c5cc66474a00bb.js"></script>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-19012543715520530272016-01-17T18:56:00.000+01:002016-01-17T18:56:06.182+01:00MPV Restore PlaybackConfigure MPV to remember playback position when closing its window so that the playback can be resumed automatically when the video is watched the next time:
<pre>
echo 'CLOSE_WIN quit_watch_later' >> ~/.config/mpv/input.conf
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-71933096781994871832015-02-27T21:49:00.001+01:002015-02-27T21:49:22.546+01:00I-Blocklist Downloader<script src="https://gist.github.com/viliampucik/3301d20c9dfdfe3c9313.js"></script>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-36128336299782392592014-11-26T21:30:00.000+01:002017-04-17T22:23:23.807+02:00Split FLAC Album Based on Cue Sheet <pre>shnsplit -f *.cue -t '%n. %t' -o flac *.flac</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-80460832249701502722014-04-01T01:03:00.000+02:002014-04-01T01:03:26.281+02:00ZeroJS<a href="https://zerojs.net/ ">ZeroJS</a> - The world's smallest JavaScript library! Zero size, zero functionality. Happy April Fool’s Day :) Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-67725549954559294002014-02-02T12:52:00.001+01:002014-02-18T22:04:59.705+01:00Android ModdingChange CRT screen off animation into fade screen off animation and minimize 48 dip high navigation bar into smaller 24 dip one.
<pre>
adb pull /system/framework/framework-res.apk
apktool d framework-res.apk
sed -e 's/<bool name="config_animateScreenLights">false<\/bool>/<bool name="config_animateScreenLights">true<\/bool>/' \
-i framework-res/res/values/bools.xml
sed -e 's/<dimen name="navigation_bar_height">.*/<dimen name="navigation_bar_height">24.0dip<\/dimen>/' \
-e 's/<dimen name="navigation_bar_height_landscape">.*/<dimen name="navigation_bar_height_landscape">24.0dip<\/dimen>/' \
-e 's/<dimen name="navigation_bar_width">.*/<dimen name="navigation_bar_width">24.0dip<\/dimen>/' \
-i framework-res/res/values/dimens.xml
apktool b framework-res
7z x framework-res/dist/framework-res.apk resources.arsc
7z u -tzip framework-res.apk resources.arsc
adb remount
adb shell mkdir /system/framework/backup
adb shell cp /system/framework/framework-res.apk /system/framework/backup
adb push framework-res.apk /system/framework
adb shell chmod 644 /system/framework/framework-res.apk
adb reboot
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-79274675540292657652013-11-17T17:55:00.000+01:002013-11-17T17:55:43.923+01:00WebOS Exchange ActiveSync User Agent<p>
Changing of Exchange ActiveSync User Agent string on HP Palm devices is done by editing <code>/usr/share/dbus-1/system-services/com.palm.eas.service</code> file:
<pre>
[D-BUS Service]
Name=com.palm.eas
Exec=/usr/bin/mojomail-eas -c {...} Palm Palm/1.0.1
</pre>
The last two strings stand for <code>Device Type</code> and <code>User Agent</code>.
</p>
<p>
In some cases changing of <code>Device ID</code> may by required as well which can be achieved using <code>Impostash</code> application (<code>Device Profile -> nduId</code>).
</p>
<p>
List of observed Device Type and User Agent strings can be obtained from <a href="http://blogs.technet.com/b/exchange/archive/2012/01/31/a-script-to-troubleshoot-issues-with-exchange-activesync.aspx">Exchange server reports</a>.
</p>
Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-23790052542618594872013-08-12T10:15:00.000+02:002013-08-12T10:15:00.484+02:00Git Basic SetupSet user and email for commits and enable colorized output:
<pre>
git config --global user.name "John Doe"
git config --global user.email john.doe@foo.com
git config --global --add color.ui true
</pre>
Optionally add couple of helpful Git aliases into your shell profile (<code>~/.bashrc</code> in case of using Bash):
<pre>
alias ga='git add'
alias gai='git add -i'
alias gc='git commit'
alias gd='git diff'
alias gdc='git diff --cached'
alias gm='git merge --no-ff'
alias gst='git status -s'
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-47475400082430101092013-04-12T21:48:00.000+02:002013-04-13T00:12:27.311+02:00SOA Checking<script src="https://gist.github.com/viliampucik/ecdd408d3c5774604d54.js"></script>
<script src="https://gist.github.com/viliampucik/863c98e688ff91e0f4ba.js"></script>
<script src="https://gist.github.com/viliampucik/a6a75aa184ed24cf4c5f.js"></script>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-54746226158415050782013-04-11T22:22:00.000+02:002015-03-28T14:04:29.862+01:00RHEL Subscription<p>
Register a new system usig RedHat username and password and subscribe it to default and optional channels:
</p>
<pre>
subscription-manager register
subscription-manager subscribe --auto
subscription-manager repos --enable=rhel-6-server-optional-rpms
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-752364684135345042013-02-26T00:34:00.000+01:002013-02-26T00:34:11.151+01:00Non-root Process Listening on Priviledged PortsAllow a user application to bind to a port below <code>1024</code> using <a href="http://blog.stalkr.net/2010/01/posix-file-capabilities.html">POSIX File Capabilities</a>:
<br />
<pre>setcap cap_net_bind_service=+eip /path/to/the/executable
</pre>
Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-86663147395968882812013-02-02T12:20:00.001+01:002013-02-02T12:20:57.418+01:00Disabling CPU CoresDisable all CPU cores except the first one which does not honor <code>online</code> attribute:
<pre>
for i in /sys/devices/system/cpu/cpu*/online; do echo 0 > $i; done
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-63452894380175383212013-01-04T01:26:00.000+01:002013-01-08T21:13:23.859+01:00There Are Too Many Ways To Do ItBenchmark of Perl text replacing subroutines as taken from <a href="http://www.shlomifish.org/lecture/Perl/Lightning/Too-Many-Ways/slides/index.html">There are too many ways to do it</a> presentation:
<script src="https://gist.github.com/4448698.js"></script>
My own results (the table is split for better readability):
<pre>
Rate delpoint8 elim_last pack01 count_and_replace sexeger
delpoint8 9237/s -- -58% -73% -82% -86%
elim_last 22232/s 141% -- -36% -58% -67%
pack01 34855/s 277% 57% -- -34% -49%
count_and_replace 52466/s 468% 136% 51% -- -23%
sexeger 68259/s 639% 207% 96% 30% --
two_parts 72359/s 683% 225% 108% 38% 6%
delpoint2 80775/s 774% 263% 132% 54% 18%
via_split 90009/s 874% 305% 158% 72% 32%
delpoint1 101626/s 1000% 357% 192% 94% 49%
rindex01 145985/s 1480% 557% 319% 178% 114%
look_ahead 163399/s 1669% 635% 369% 211% 139%
Rate two_parts delpoint2 via_split delpoint1 rindex01 look_ahead
delpoint8 9237/s -87% -89% -90% -91% -94% -94%
elim_last 22232/s -69% -72% -75% -78% -85% -86%
pack01 34855/s -52% -57% -61% -66% -76% -79%
count_and_replace 52466/s -27% -35% -42% -48% -64% -68%
sexeger 68259/s -6% -15% -24% -33% -53% -58%
two_parts 72359/s -- -10% -20% -29% -50% -56%
delpoint2 80775/s 12% -- -10% -21% -45% -51%
via_split 90009/s 24% 11% -- -11% -38% -45%
delpoint1 101626/s 40% 26% 13% -- -30% -38%
rindex01 145985/s 102% 81% 62% 44% -- -11%
look_ahead 163399/s 126% 102% 82% 61% 12% --
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-87619752731728565082012-11-15T11:38:00.000+01:002012-11-15T11:38:23.810+01:00SSH Agent Forwarding for "sudo su"Exporting of <code>SSH_AUTH_SOCK</code> environment variable when using <code>sudo su</code> enables forwarding of user's SSH agent connection to root environment
<pre>
(umask 0440; echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/ssh-auth-sock)
</pre>
Example of using <code>/etc/sudoers.d/ssh-auth-sock</code> on <code>host</code> machine. The example assumes that the user copied already their public SSH key to the destination machines under root user:
<pre>
$ ssh -A user@host
[user@host]$ sudo su
[root@host]# ssh remote
[root@remote]#
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-84046563237271327592012-08-20T19:55:00.000+02:002012-08-20T19:55:21.281+02:00dos2unix & unix2dosConvert file with Windows line endings to UNIX and vice versa, all in Perl:
<pre>
perl -i -pe 's/\r//g' dos2unix
perl -i -pe 's/\n/\r\n/g' unix2dos
</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-76290539755692890082012-07-29T18:47:00.000+02:002013-11-14T22:58:26.214+01:00GRUB2 Multiboot USB StickBooting <a href="http://www.sysresccd.org/Download">SystemRescudeCd</a> and Windows 7 Installation from a USB stick using GRUB2. Assuming that <code>/dev/sdb1</code> is an NTFS formated partition mounted under <code>/mnt/usb</code>:
<ol>
<li>Copy the whole content of Windows 7 DVD directly into <code>/mnt/usb</code>.</li>
<li>Copy <code>sysrcd.dat</code>, <code>sysrcd.md5</code>, <code>isolinux/initram.igz</code> and <code>isolinux/rescue64</code> from SystemRescudeCd ISO image into <code>/mnt/usb/linux</code>.
</li>
<li>Install GRUB2 to the USB stick:
<pre>
grub-install --no-floppy --root-directory=/mnt/usb /dev/sdb
</pre>
</li>
<li>Edit <code>/mnt/usb/boot/grub/grub.cfg</code>, e.g.:
<pre>
set timeout=5
set default=0
menuentry "System Rescue CD 64bit" {
linux /linux/rescue64 subdir=linux scandelay=1 docache nomodeset
initrd /linux/initram.igz
}
menuentry "Windows 7 Installation" {
ntldr /bootmgr
}
</pre>
</li>
</ol>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com1tag:blogger.com,1999:blog-4443372841240745511.post-88939281486777686692012-06-20T02:08:00.000+02:002012-06-20T02:19:05.689+02:00PingICMP echo request alias ping:
<pre>perl -MNet::Ping -lne 'print "$_: ", scalar Net::Ping->new( "icmp" )->ping( $_ )' hosts.txt</pre>
TCP based ping using port 80:
<pre>perl -MNet::Ping -lne '$p = Net::Ping->new; $p->port_number( 80 );
print "$_: ", scalar $p->ping( $_ )' hosts.txt</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-3964960413887906192012-06-20T01:42:00.000+02:002012-06-20T01:48:23.676+02:00Blocking Traffic Using Null RouteBlocking network traffic for a specific host without using <code>iptables</code>:
<pre>ip route add blackhole 10.0.0.1/32</pre>
To remove the rule:
<pre>ip route del blackhole 10.0.0.1/32</pre>
Compared to <code>iptables</code> a null route has no effect on loopback addresses (127.0.0.0/8).Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0tag:blogger.com,1999:blog-4443372841240745511.post-64054801417137568092012-06-19T09:17:00.002+02:002012-06-19T09:17:45.289+02:00Erase Old FilesErase files older than 7 days:
<pre>find -mtime +7 -exec rm -rf {} \;</pre>Viliam Pucikhttp://www.blogger.com/profile/13030228791535688775noreply@blogger.com0