<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Techie Stuff &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Fri, 07 Mar 2025 13:16:19 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>Reset SnappyMail admin portal password</title>
		<link>https://luxing.im/reset-snappymail-admin-portal-password/</link>
					<comments>https://luxing.im/reset-snappymail-admin-portal-password/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Fri, 07 Mar 2025 13:16:19 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[reset]]></category>
		<category><![CDATA[snappymail]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=969</guid>

					<description><![CDATA[SnappyMail is a successor of RainLoop and most importantly, SnappyMail is maintained. When I was trying to login to the SnappyMail admin portal via /?admin URL, I couldn&#8217;t remember the password and the password manager does not have the record either. It is time to reset the password. It is pretty easy. Login to your &#8230; <p class="link-more"><a href="https://luxing.im/reset-snappymail-admin-portal-password/" class="more-link">Continue reading<span class="screen-reader-text"> "Reset SnappyMail admin portal password"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>SnappyMail is a successor of RainLoop and most importantly, SnappyMail is maintained. When I was trying to login to the SnappyMail admin portal via /?admin URL, I couldn&#8217;t remember the password and the password manager does not have the record either.</p>
<p><span id="more-969"></span></p>
<p>It is time to reset the password. It is pretty easy.</p>
<ol>
<li>Login to your server and go to your SnappyMail php folder.</li>
<li>Go to data/<em>data</em>/<em>default</em>/configs folder</li>
<li>Edit the file called application.ini</li>
<li>Find out the line admin_password and remove such line.</li>
<li>Refresh the /?admin web page</li>
<li>Go 1 upper level folder (i.e. data/<em>data</em>/<em>default</em>)</li>
<li>There is a new file admin_password.txt generated for you and you can cat it to see the password.</li>
</ol>
<p>Now you can use this password to login. You are able to change the admin password after logging in to the admin portal.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/reset-snappymail-admin-portal-password/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">969</post-id>	</item>
		<item>
		<title>Lenovo Legion 5 Gen 6 AMD with nvidia backlight issue under Manjaro</title>
		<link>https://luxing.im/lenovo-legion-5-gen-6-amd-with-nvidia-backlight-issue-under-manjaro/</link>
					<comments>https://luxing.im/lenovo-legion-5-gen-6-amd-with-nvidia-backlight-issue-under-manjaro/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Thu, 08 Jul 2021 19:03:05 +0000</pubDate>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=891</guid>

					<description><![CDATA[The Legion 5 Gen 6 AMD Ryzen with NVIDIA graphics (15ACH6H, model 82JU00APUS) is what I have on my hand. The Linux system I use is Manjaro due to its simplicity. I&#8217;ve experienced a very common backlight issue, Fn key won&#8217;t adjust the backlight at all, it&#8217;s always on 100% brightness. I use discrete / &#8230; <p class="link-more"><a href="https://luxing.im/lenovo-legion-5-gen-6-amd-with-nvidia-backlight-issue-under-manjaro/" class="more-link">Continue reading<span class="screen-reader-text"> "Lenovo Legion 5 Gen 6 AMD with nvidia backlight issue under Manjaro"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>The Legion 5 Gen 6 AMD Ryzen with NVIDIA graphics (15ACH6H, model 82JU00APUS) is what I have on my hand. The Linux system I use is Manjaro due to its simplicity. I&#8217;ve experienced a very common backlight issue, Fn key won&#8217;t adjust the backlight at all, it&#8217;s always on 100% brightness. I use discrete / dedicated nvidia graphics all the time, so this solution may not be suitable for everyone.</p>
<p><span id="more-891"></span></p>
<p>Here are the steps I tried with my setup, all commands are executed as root:</p>
<p>1 Install manjaro with proprietary driver (nvidia-drm), not nouveau open source driver.</p>
<p>2 Generate xorg.conf with <code>nvidia-xconfig</code></p>
<p>3 Write the following content to /etc/X11/xorg.conf.d/20-nvidia-backlight.conf</p>
<pre>
Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection
</pre>
<p>4 Add these kernel parameters to <code>/etc/default/grub</code>:</p>
<pre>amdgpu.backlight=0 acpi_backlight=vendor</pre>
<p>And run <code>update-grub</code></p>
<p>5 Reboot into the newly configured kernel.</p>
<p>6 Test if we can adjust the backlight via setting system values:</p>
<pre>echo "50" > /sys/class/backlight/nvidia_0/brightness</pre>
<p>If it works, we are able to use acpi events to tune the brightness.</p>
<p>7 Enable and start the acpid service.</p>
<pre>systemctl enable acpid</pre>
<p>then start</p>
<pre>systemctl start acpid</pre>
<p>and then monitor its logs</p>
<pre>journalctl -u acpid -f</pre>
<p>8 Press Fn+F5 or Fn+F6 key to toggle brightness up/down, we should see the acpid complain about <code>ACPI group/action undefined: video/brightnessup</code> or brightnessdown. If we do not see this error, then the next thing won&#8217;t work.</p>
<p>9 Assuming we can see the undefined error, we can write some scripts to override the brightness value.</p>
<pre>
cd /etc/acpi
mkdir handlers

cd handlers
</pre>
<p>vim backlight and paste the following content to it</p>
<pre>
#!/bin/sh
bl_dev=/sys/class/backlight/nvidia_0
step=6

case $1 in
  -) echo $(($(< $bl_dev/brightness) - $step)) >$bl_dev/brightness;;
  +) echo $(($(< $bl_dev/brightness) + $step)) >$bl_dev/brightness;;
esac
</pre>
<p>Let&#8217;s continue.</p>
<pre>
chmod +x backlight

cd ../events
</pre>
<p>vim bl_d and copy the following script to it</p>
<pre> 
event=video/brightnessdown
action=/etc/acpi/handlers/backlight -
</pre>
<p>vim bl_u and copy the following script to it</p>
<pre>
event=video/brightnessup
action=/etc/acpi/handlers/backlight +
</pre>
<p>10 Restart acpid service</p>
<pre>systemctl restart acpid</pre>
<p>11 Use your Fn+F5 or Fn+F6 to adjust brightness, note the value presented on your screen does not reflect the real brightness.</p>
<p>ACPI example usages and docs: <a href="https://wiki.archlinux.org/title/Acpid#Enabling_backlight_control" rel="noopener" target="_blank">https://wiki.archlinux.org/title/Acpid#Enabling_backlight_control</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/lenovo-legion-5-gen-6-amd-with-nvidia-backlight-issue-under-manjaro/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">891</post-id>	</item>
		<item>
		<title>Screenshot crop to clipboard under Linux</title>
		<link>https://luxing.im/screenshot-crop-to-clipboard-under-linux/</link>
					<comments>https://luxing.im/screenshot-crop-to-clipboard-under-linux/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Tue, 27 Apr 2021 02:08:18 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=882</guid>

					<description><![CDATA[Now Manjaro is my major operating system for my desktop, I am joining the Arch team! With so many documentations available online it&#8217;s been a really good ride to customize my OS to my taste. Today I am gonna talk about my use for taking a screenshot, cropping it and copy it to the clipboard. &#8230; <p class="link-more"><a href="https://luxing.im/screenshot-crop-to-clipboard-under-linux/" class="more-link">Continue reading<span class="screen-reader-text"> "Screenshot crop to clipboard under Linux"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Now Manjaro is my major operating system for my desktop, I am joining the Arch team! With so many documentations available online it&#8217;s been a really good ride to customize my OS to my taste. Today I am gonna talk about my use for taking a screenshot, cropping it and copy it to the clipboard.</p>
<p><span id="more-882"></span></p>
<p>Most of the people when doing a screenshot doesn&#8217;t want the full screen to be captured, only the necessary part. Copying the picture to clipboard will also help you to paste it directly to applications like WYSIWYG editors or Telegram. I&#8217;ve written a 2 liner script that I can invoke to achieve this goal.</p>
<p>We will utilize the power of <a href="https://archlinux.org/packages/community/x86_64/scrot/" rel="noopener" target="_blank">scrot</a> tool. So first you need to install scrot.</p>
<p><code>sudo pacman -S scrot</code></p>
<p>Now let&#8217;s write a script called screenshot and save it as an executable file under one of the folders under your PATH variable.</p>
<p><code><br />
#!/bin/bash<br />
rm -rf /tmp/xclip.png<br />
scrot -s /tmp/xclip.png<br />
xclip -sel clipboard -t image/png -i &lt; /tmp/xclip.png<br />
</code></p>
<p>This way the /tmp/xclip.png file will be overridden every time you take a screenshot, also it provides the capability to use the file every time after you&#8217;ve taken a screenshot.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/screenshot-crop-to-clipboard-under-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">882</post-id>	</item>
		<item>
		<title>Purchased a Minisforum X35G</title>
		<link>https://luxing.im/purchased-a-minisforum-x35g/</link>
					<comments>https://luxing.im/purchased-a-minisforum-x35g/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Wed, 16 Dec 2020 22:49:03 +0000</pubDate>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[mini pc]]></category>
		<category><![CDATA[pc]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=867</guid>

					<description><![CDATA[Just when I was thinking of what gift to buy for myself for the Christmas holiday, I came to an Indiegogo crowd funding project: Minisforum X35G. And I suddenly realized that I need to use a mini PC to replace my 5-year-old Lenovo Y50P laptop running as my side router. I have the following reasons &#8230; <p class="link-more"><a href="https://luxing.im/purchased-a-minisforum-x35g/" class="more-link">Continue reading<span class="screen-reader-text"> "Purchased a Minisforum X35G"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Just when I was thinking of what gift to buy for myself for the Christmas holiday, I came to an Indiegogo crowd funding project: <a href="https://www.indiegogo.com/projects/the-new-core-intel-10nm-minis/x/25145204#/" rel="noopener" target="_blank">Minisforum X35G</a>.</p>
<p><span id="more-867"></span></p>
<p>And I suddenly realized that I need to use a mini PC to replace my 5-year-old Lenovo Y50P laptop running as my side router. I have the following reasons to deprecate my laptop:</p>
<ol>
<li>It was a gaming laptop (from 2015), so power consumption is not low.</li>
<li>It was a laptop after all, not suppose to run 24&#215;7 like a router or server.</li>
<li>I may need to use the laptop, even boot into a Windows OS for some tasks/tests, then all devices connected to this side router will be disconnected from the Internet.</li>
<li>I setup LUKS encrypted disk earlier, every time I need to type password when boot / reboot.</li>
<li>Fedora 31 is installed, now deprecated.</li>
</ol>
<p>Mini PCs are perfect for this task. I know using a Mini PC as a side router is a little overkill, with the new server I am able to run more stuff in our little machine.</p>
<p>The X35G has a 10th generation Intel CPU <a href="https://ark.intel.com/content/www/us/en/ark/products/196588/intel-core-i3-1005g1-processor-4m-cache-up-to-3-40-ghz.html" rel="noopener" target="_blank">i3-1005G1</a>.</p>
<p>Let&#8217;s take a look at the little thing.</p>
<p>The front and side:<br />
<img decoding="async" src="https://ext2.ke.fo/2020/12/16/Image_20201215_1536527019087705740543560.jpg" alt="" /></p>
<p>The back:<br />
<img decoding="async" src="https://ext2.ke.fo/2020/12/16/Image_20201215_1536345903288731777928109.jpg" alt="" /></p>
<p>This little machine is about the size of Mac Mini, the entire chassis is made of aluminium, the hand feel is great!</p>
<p>I am not going to go through the specs, you can find it out on its <a href="https://store.minisforum.com/products/minisforum-x35g-mini-pc" rel="noopener" target="_blank">official website</a>.</p>
<p>The version I got is the cheapest one from Indiegogo, which does not come with a M.2 NVMe disk because I have a left-over <a href="https://www.amazon.ca/gp/product/B07J2WBKXF/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&#038;psc=1" rel="noopener" target="_blank">NVMe disk</a> from my junk desktop PC. The disassembly process is a little tricky, the NVMe slot is at the back of the motherboard which you need to unscrew all screws to see, but still, it is a good practise for enthusiasts like me.</p>
<p><img decoding="async" src="https://ext2.ke.fo/2020/12/16/Image_20201215_1603058826270590755926528.jpg" alt="" /></p>
<p>At work, I have been using CentOS, Amazon Linux, RHEL and Ubuntu the most of the time, I do want to get a taste in ArchLinux. The OS I installed is Manjaro Architect 20.0.3. The boot time is about 10s.</p>
<p>UnixBench mark: 3467.8. I can barely hear the fan on full load. My furnace is even louder than that.</p>
<pre>
Dhrystone 2 using register variables      133599372.3 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    26195.5 MWIPS (9.9 s, 7 samples)
Execl Throughput                              15115.9 lps   (29.8 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1207122.0 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          337511.7 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3982041.8 KBps  (30.0 s, 2 samples)
Pipe Throughput                             4874841.9 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 752660.2 lps   (10.0 s, 7 samples)
Process Creation                              31625.7 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  10665.2 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1553.2 lpm   (60.1 s, 2 samples)
System Call Overhead                        4602072.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  133599372.3  11448.1
Double-Precision Whetstone                       55.0      26195.5   4762.8
Execl Throughput                                 43.0      15115.9   3515.3
File Copy 1024 bufsize 2000 maxblocks          3960.0    1207122.0   3048.3
File Copy 256 bufsize 500 maxblocks            1655.0     337511.7   2039.3
File Copy 4096 bufsize 8000 maxblocks          5800.0    3982041.8   6865.6
Pipe Throughput                               12440.0    4874841.9   3918.7
Pipe-based Context Switching                   4000.0     752660.2   1881.7
Process Creation                                126.0      31625.7   2510.0
Shell Scripts (1 concurrent)                     42.4      10665.2   2515.4
Shell Scripts (8 concurrent)                      6.0       1553.2   2588.7
System Call Overhead                          15000.0    4602072.3   3068.0
                                                                   ========
System Benchmarks Index Score                                        3467.8
</pre>
<p>The memory used with all the existing customized service is: 269MB / 15.4GB. I have a lot to explore!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/purchased-a-minisforum-x35g/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">867</post-id>	</item>
		<item>
		<title>Make virtual ethernet the default</title>
		<link>https://luxing.im/make-virtual-ethernet-the-default/</link>
					<comments>https://luxing.im/make-virtual-ethernet-the-default/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Mon, 20 Jul 2020 03:34:52 +0000</pubDate>
				<category><![CDATA[Learning Notes]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[vm]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=845</guid>

					<description><![CDATA[Recently I leased a server with 2 IPs, x.x.x.x and y.y.y.y from a VPS company. Their first IP is the primary one and is connected to my VM, the secondary IP y.y.y.y is there for me to use, but have not connected yet. Given the following status quo: The primary x.x.x.x is a great IP &#8230; <p class="link-more"><a href="https://luxing.im/make-virtual-ethernet-the-default/" class="more-link">Continue reading<span class="screen-reader-text"> "Make virtual ethernet the default"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Recently I leased a server with 2 IPs, x.x.x.x and y.y.y.y from a VPS company. Their first IP is the primary one and is connected to my VM, the secondary IP y.y.y.y is there for me to use, but have not connected yet.</p>
<p><span id="more-845"></span><br />
Given the following status quo:</p>
<p>The primary x.x.x.x is a great IP and has good connectivity all over the world, however their y.y.y.y secondary IP has a premium networking route to certain places in the world in addition. I&#8217;d like to have both IP working in the mean time make y.y.y.y the default IP. My operating system is CentOS 7.</p>
<p>I would like to achieve the goal of:<br />
1. Add y.y.y.y to the system<br />
2. Make y.y.y.y the default IP, if seen from outside world.<br />
3. Keep the primary x.x.x.x IP available and connected just in case for failover.</p>
<p>So here is how I did it:</p>
<ol>
<li>Copy from ifcfg-eth0 to ifcfg-eth0:1 and change ifcfg-eth0:1 file in /etc/sysconfig/network-scripts</li>
<pre>
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0:1
GATEWAY=y.y.y.1
HWADDR=be:ef:be:ef:be:ef
IPADDR=y.y.y.y
IPV6INIT=no
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
</pre>
<p>Here BOOTPROTO must be none, make sure you keep the MAC address the same as ifcfg-eth0 and replace the values I obfuscated.</p>
<li>Modify ifcfg-eth0 file with DEFROUTE=no</li>
<li>Add a static route to make sure. Create a file route-eth0 in /etc/sysconfig/network-scripts</li>
<pre>
default via y.y.y.1 dev eth0:1
</pre>
<li>Restart network service</li>
<pre>systemctl restart network</pre>
<li>Confirm your IP and route</li>
<pre>
# confirm IP:
ip a

# confirm route:
ip ro
</pre>
</ol>
<p>And your VM&#8217;s default IP to the outside world should be y.y.y.y now.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/make-virtual-ethernet-the-default/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">845</post-id>	</item>
		<item>
		<title>Put CPU under Performance mode in Linux</title>
		<link>https://luxing.im/put-cpu-under-performance-mode-in-linux/</link>
					<comments>https://luxing.im/put-cpu-under-performance-mode-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sun, 02 Feb 2020 07:13:46 +0000</pubDate>
				<category><![CDATA[Learning Notes]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[frequency]]></category>
		<category><![CDATA[tuning]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=832</guid>

					<description><![CDATA[Linux kernel is able to control every tiny bit of the hardware it operates. This time I am going to max out my server&#8217;s CPU performance by tuning the CPU to the performance mode. I have been renting a dedicated server for a long time, on the server I have been hosting a few virtual &#8230; <p class="link-more"><a href="https://luxing.im/put-cpu-under-performance-mode-in-linux/" class="more-link">Continue reading<span class="screen-reader-text"> "Put CPU under Performance mode in Linux"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Linux kernel is able to control every tiny bit of the hardware it operates. This time I am going to max out my server&#8217;s CPU performance by tuning the CPU to the performance mode.</p>
<p><span id="more-832"></span></p>
<p>I have been renting a dedicated server for a long time, on the server I have been hosting a few virtual servers to serve my needs. In order to bring up the performance a little bit, I decide to bring the CPU frequency in high ranges at all times.</p>
<p>The raw way is to put <code>performance</code> (should be defined in <code>/sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors</code>) to <code>/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor</code></p>
<p>Now if my server has 1 or 2 cores, I may just change the cpu0 and cpu1 values directly, but what if I have 32 cores or even more? Human errors will occur while scripting. We have command line tools to help us changing the governor instead, it is called <code>cpupower</code>.</p>
<p>All commands are run under root.</p>
<h3>Install cpupower</h3>
<p>On CentOS, cpupower is brought by <code>kernel-tools</code> package.</p>
<pre>yum install kernel-tools -y</pre>
<h3>Turn on cpupower service</h3>
<pre>
systemctl daemon-reload
systemctl enable cpupower
systemctl start cpupower
</pre>
<p>Now by your definition of the cpupower service, you may have already turned on performance mode, please check any of the scaling_governor file.</p>
<h3>Make machine performant</h3>
<pre>
cpupower frequency-set -g performance</h3>
</pre>
<p>You should be set. Check your CPU cores by <code>watch -s 2 cat /proc/cpuinfo</code> (control+c terminates watch)<br />
Your CPU cores should be running at high frequency range at all times.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/put-cpu-under-performance-mode-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">832</post-id>	</item>
		<item>
		<title>mutt integration with Gmail using OAuth</title>
		<link>https://luxing.im/mutt-integration-with-gmail-using-oauth/</link>
					<comments>https://luxing.im/mutt-integration-with-gmail-using-oauth/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Tue, 30 Jul 2019 15:15:41 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[terminal]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=813</guid>

					<description><![CDATA[As I mentioned before, I am a heavy terminal user, including viewing and replying emails with it. Mutt is my email client. Once you have setup your 2 factor authentication with Google, you won&#8217;t be able to access your Gmail using IMAP with your password, you&#8217;ll have to generate a specific password for the so &#8230; <p class="link-more"><a href="https://luxing.im/mutt-integration-with-gmail-using-oauth/" class="more-link">Continue reading<span class="screen-reader-text"> "mutt integration with Gmail using OAuth"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>As I <a href="https://luxing.im/using-mutt-as-email-client/">mentioned</a> before, I am a heavy terminal user, including viewing and replying emails with it. Mutt is my email client. Once you have setup your 2 factor authentication with Google, you won&#8217;t be able to access your Gmail using IMAP with your password, you&#8217;ll have to generate a specific password for the so called <a href="https://support.google.com/a/answer/6260879">&#8220;Less Secure Apps&#8221;</a>. There is a problem with that, if you use IMAP with less-secure-app password on your company account where &#8220;less secure app&#8221; is not allowed, you are probably stuck.</p>
<p>In this tutorial, I am going to show you how to setup the Google recommended OAuth 2.0 way with Mutt.</p>
<p><span id="more-813"></span></p>
<p>Remember, the OAuth client setup should be an one-time step, it should be usable for your different email addresses on Gmail, that includes your work email if your employer choose Gmail as their email service provider, as long as you authorize permission during the OAuth App.</p>
<ol>
<li>Login to your google account, navigate to https://console.cloud.google.com/apis/credentials and if this page says anything API not enabled, enable it.</li>
<li>In the credentials page, create a project.</li>
<li>After creating the project, you should be able to go to the OAuth consent screen tab, put something recognizable in the application name, click save.</li>
<li>Go back to &#8220;Credentials&#8221; page and click on &#8220;Create credentials&#8221; button and select OAuth client ID.</li>
<li>Select other and click create. You&#8217;ll be given an OAuth client ID and secret. You can view the id and secret anytime.</li>
</ol>
<p>Now you&#8217;ve setup an OAuth client, it is time for mutt configuration.</p>
<p>Download oauth2.py from GitLab: <a href="https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py" rel="noopener noreferrer" target="_blank">https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py</a> and make it executable. You&#8217;ll need to run the command to generate an OAuth token.</p>
<p>Fill your Google App client id and secret here: <a href="https://gitlab.com/muttmua/mutt/-/blob/5347d1c5c0f529ad7e1464ce9f1716d54ed9c31a/contrib/mutt_oauth2.py#L61" rel="noopener" target="_blank">https://gitlab.com/muttmua/mutt/-/blob/5347d1c5c0f529ad7e1464ce9f1716d54ed9c31a/contrib/mutt_oauth2.py#L61</a> and Line 62.</p>
<p>Execute the following command to authorize yourself.</p>
<pre>
mutt_oauth2.py userid@myschool.edu.tokens --verbose --authorize
</pre>
<p>Open the web browser with the link given and authenticate yourself, login and grant permission.</p>
<p>The way I manage my files under <code>~/.mutt</code>:</p>
<pre>
.
|-- accounts
|   |-- gmail.asc
|   |-- account2.asc
|   |-- account3.asc
|-- mailcap
|-- muttrc
|-- oauth2.py
...
</pre>
<p>The muttrc master config file only manage generic stuff such as header and format stuff, it also has some macro to map function keys to switch accounts. The actual accounts are under <code>~/.mutt/accounts</code> folder with GPG encryption in ASCII.</p>
<p>The original gmail file should only contain account related stuff, such as IMAP and SMTP configuration. At the core the login lines should be:</p>
<pre>
set imap_user = "your@gmail.com" 
set imap_authenticators="oauthbearer"
set imap_oauth_refresh_command="~/.mutt/mutt_oauth2.py ~/.mutt/tokens/gmail"
set smtp_authenticators="oauthbearer"
set smtp_oauth_refresh_command="~/.mutt/mutt_oauth2.py ~/.mutt/tokens/gmail"
set smtp_url = "smtp://your@gmail.com@smtp.gmail.com:587/"
set from = "your@gmail.com" 
set realname = "Your Name"
set signature = "~/.mutt/signatures/mysig"

# Basic config, you can leave this as is 
set folder = "imaps://imap.gmail.com"
set spoolfile = "+INBOX"
set imap_check_subscribed 
set postponed = "+[Gmail]/Draft"
set record = ""
set header_cache=~/.mutt/cache/headers
</pre>
<p>You should be able to use mutt to view/send emails via Gmail using OAuth 2.0!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/mutt-integration-with-gmail-using-oauth/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">813</post-id>	</item>
		<item>
		<title>GitLab LFS setup</title>
		<link>https://luxing.im/gitlab-lfs-setup/</link>
					<comments>https://luxing.im/gitlab-lfs-setup/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sun, 30 Dec 2018 19:42:38 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[gitlab]]></category>
		<category><![CDATA[lfs]]></category>
		<category><![CDATA[storage]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=789</guid>

					<description><![CDATA[Recently I was playing around with GitLab LFS setup, although the documentation on GitLab website has most of the technical background however there are a few details and examples missing. I&#8217;ll complement some of them here. The official documentation is located here: https://docs.gitlab.com/ce/workflow/lfs/lfs_administration.html My setup is: Omnibus GitLab + Google Cloud Storage (GCS) bucket. Step &#8230; <p class="link-more"><a href="https://luxing.im/gitlab-lfs-setup/" class="more-link">Continue reading<span class="screen-reader-text"> "GitLab LFS setup"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Recently I was playing around with GitLab LFS setup, although the documentation on GitLab website has most of the technical background however there are a few details and examples missing. I&#8217;ll complement some of them here.<br />
<span id="more-789"></span></p>
<p>The official documentation is located here: https://docs.gitlab.com/ce/workflow/lfs/lfs_administration.html</p>
<p>My setup is: Omnibus GitLab + Google Cloud Storage (GCS) bucket.</p>
<h2>Step 1</h2>
<p>You&#8217;ll need to setup a GCP project and a service account with a particular bucket&#8217;s admin permission assigned. Download the json and upload it to GitLab instance. Let&#8217;s assume it is located at <code>/etc/gitlab/gcs.json</code></p>
<p><strong>Gotcha 1</strong>: when file permission is 600 with root:root u/g, gitlab will not be able to read the key. It needs to be set as <code>git:git</code> u/g, or 644 permission (not safe). This is not specified in GitLab documentation.</p>
<h2>Step 2</h2>
<p>Setup LFS server configuration in <code>gitlab.rb</code></p>
<p><strong>Gotcha 2</strong>: No full example of how things should be setup. Here is my working setup example related to LFS:</p>
<pre>
gitlab_rails['lfs_enabled'] = true
gitlab_rails['lfs_object_store_enabled'] = true # Optional, default to false
gitlab_rails['lfs_object_store_direct_upload'] = true # Optional, default to false
gitlab_rails['lfs_object_store_remote_directory'] = 'bucket-name'
gitlab_rails['lfs_object_store_proxy_download'] = true
gitlab_rails['lfs_object_store_connection'] = {
  'provider' => 'Google',
  'google_project' => 'gcp_project_name',
  'google_client_email' => 'service-account@gcp_project_name.iam.gserviceaccount.com',
  'google_json_key_location' => '/etc/gitlab/gcs.json'
}
</pre>
<p>Obviously you need to reconfigure gitlab after applying such configuration.</p>
<h2>Step 3</h2>
<p>Setup a LFS enabled repo and test.</p>
<p>Setting up a LFS repo is pretty straightforward, there are plenty of tutorials available online. Let&#8217;s assume that the LFS files are not being referenced at all in other GitLab projects.</p>
<h2>Step 4</h2>
<p>LFS object removal</p>
<p>This is the most head-aching part of GitLab, according to this <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14479" rel="noopener" target="_blank">issue</a>, this is still work-in-progress, however the function is actually already implemented in GitLab.</p>
<p><strong>Gotcha 3</strong>: Assume project deletion, all LFS files are no longer referenced anymore and when you see GCS you still see the files there occupying the space. GitLab actually removes LFS remote files as a cron job, the detail is not documented. In your https://git/admin/background_jobs page select Cron, there is a background job called <code>remove_unreferenced_lfs_objects_worker</code> which you can manually trigger in order to remove LFS remote files immediately, or just wait until the next cron execution.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/gitlab-lfs-setup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">789</post-id>	</item>
		<item>
		<title>tmux select then copy to clipboard</title>
		<link>https://luxing.im/tmux-select-then-copy/</link>
					<comments>https://luxing.im/tmux-select-then-copy/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sun, 25 Nov 2018 20:21:51 +0000</pubDate>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[paste]]></category>
		<category><![CDATA[tmux]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=776</guid>

					<description><![CDATA[Using mouse to select text with tmux sometimes is inefficient. For my setup, I&#8217;ll have to press shift key during text selection and keyboard copy will convert empty line as spaces. The following 2 lines in the configuration file works with version 2.8 (latest at the time of writing). As I am using Linux, the &#8230; <p class="link-more"><a href="https://luxing.im/tmux-select-then-copy/" class="more-link">Continue reading<span class="screen-reader-text"> "tmux select then copy to clipboard"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Using mouse to select text with tmux sometimes is inefficient. For my setup, I&#8217;ll have to press shift key during text selection and keyboard copy will convert empty line as spaces. The following 2 lines in the configuration file works with version 2.8 (latest at the time of writing).</p>
<p><span id="more-776"></span></p>
<p>As I am using Linux, the command line clipboard program is <code>xclip</code>. For mac users you need to use <code>pbcopy</code>.</p>
<p>Add those lines to your <code>~/.tmux.conf</code></p>
<pre>
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -i -sel c"
</pre>
<p>Now when you are on the select mode (<code>prefix+[</code>), hit v or space to start selecting. After, press y to yank lines to clipboard. You can paste it anywhere else.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/tmux-select-then-copy/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">776</post-id>	</item>
		<item>
		<title>Currency Conversion on Bash</title>
		<link>https://luxing.im/currency-conversion-on-bash/</link>
					<comments>https://luxing.im/currency-conversion-on-bash/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Tue, 06 Nov 2018 20:11:48 +0000</pubDate>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[currency]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[tools]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=770</guid>

					<description><![CDATA[Currency.sh I had an idea long ago to convert currency on bash. So first you need a live currency conversion API in order to get a most up-to-date conversion rate data, preferably free. After searching through the internet, this one is a good API. I&#8217;ve been using it for some time and normally it is &#8230; <p class="link-more"><a href="https://luxing.im/currency-conversion-on-bash/" class="more-link">Continue reading<span class="screen-reader-text"> "Currency Conversion on Bash"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><a href="https://luxing.im/wp-content/uploads/2018/11/currency.png"><img decoding="async" src="https://luxing.im/wp-content/uploads/2018/11/currency-300x108.png" alt="" width="300" height="108" class="alignleft size-medium wp-image-771" srcset="https://luxing.im/wp-content/uploads/2018/11/currency-300x108.png 300w, https://luxing.im/wp-content/uploads/2018/11/currency.png 343w" sizes="(max-width: 300px) 100vw, 300px" /></a> Currency.sh<br />
<span id="more-770"></span></p>
<p>I had an idea long ago to convert currency on bash.</p>
<p>So first you need a live currency conversion API in order to get a most up-to-date conversion rate data, preferably free. After searching through the internet, <a href="https://free.currencyconverterapi.com/" rel="noopener noreferrer" target="_blank">this one</a> is a good API. I&#8217;ve been using it for some time and normally it is quite stable.</p>
<p>The only dependency you need to install is jq, please use your package manager to install.</p>
<p>Usage:</p>
<pre>currency.sh <currency1> <currency2> [quantity]</pre>
<p>You currency code must meet <a href="https://en.wikipedia.org/wiki/ISO_4217" rel="noopener noreferrer" target="_blank">ISO 4217</a> standard.</p>
<p>Script:</p>
<pre>
#!/bin/bash
jq 2> /dev/null
if [ "$?" != 2 ]; then
  echo "Please install jq"
  exit 1
fi

if [ -z "$1" -o -z "$2" ]; then
  echo "Please provide first and second currency."
  echo "e.g. $0 CAD USD [amount]"
  exit 1
fi

currency1=`echo -n $1 | tr '[:lower:]' '[:upper:]'`
currency2=`echo -n $2 | tr '[:lower:]' '[:upper:]'`

unit_price_f=$(curl -s "https://free.currencyconverterapi.com/api/v5/convert?q=${currency1}_${currency2}&compact=y" | jq ".${currency1}_${currency2}.val")

unit_price=$(printf "%.8f" $unit_price_f)

echo Unit price buy $1 from $2 is $unit_price.

if [ ! -z "$3" ]; then
  echo
  echo -n "$3 $1 is "
  echo "$3 * $unit_price" | bc -l | tr -d "\n"
  echo " $2"
fi
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/currency-conversion-on-bash/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">770</post-id>	</item>
	</channel>
</rss>
