<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Code on xie</title>
		<link>https://xie.oskarsh.ru/tags/code/</link>
		<description>Recent content in Code on xie</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
			<copyright>© Oskar Sharipov - 2026 - CC BY-SA 4.0</copyright>
		
		
			<lastBuildDate>Mon, 31 Jul 2023 21:54:52 +0700</lastBuildDate>
		
			<atom:link href="https://xie.oskarsh.ru/tags/code/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Batch PDF Editing</title>
				<link>https://xie.oskarsh.ru/post/pdf/</link>
				<pubDate>Mon, 31 Jul 2023 21:54:52 +0700</pubDate>
				<guid>https://xie.oskarsh.ru/post/pdf/</guid>
				<description>&lt;p&gt;I needed to do batch operations with images and get a merged PDF output. Desiring to&#xA;minimize a number of tools, at the end I&amp;rsquo;ve done all processing with ImageMagick and&#xA;Ghostscript. Zsh and GNU parallel were also my friends.&lt;/p&gt;&#xA;&lt;h4 id=&#34;convert-and-chop-4-sides&#34;&gt;Convert and Chop 4 sides&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;convert input.png -crop +300+300 -crop -300-300 output.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;convert-and-rotate&#34;&gt;Convert and Rotate&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;convert input.png -rotate -90 -page A4 output.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;convert-many-files-in-parallel&#34;&gt;Convert many files in parallel&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;find . -name &lt;span class=&#34;s1&#34;&gt;&amp;#39;*.jpg&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; parallel convert &lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;.&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;merge-and-optimize&#34;&gt;Merge and optimize&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gs -dBATCH -dNOPAUSE -q -sDEVICE&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;pdfwrite -dPDFSETTINGS&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;/ebook -sOutputFile&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;merged.pdf &lt;span class=&#34;se&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;one.pdf two.pdf three.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Result file will be optimized because of &lt;code&gt;-dPDFSETTINGS=/ebook&lt;/code&gt;.&lt;/p&gt;</description>
				<content:encoded>&lt;p&gt;I needed to do batch operations with images and get a merged PDF output. Desiring to&#xA;minimize a number of tools, at the end I&amp;rsquo;ve done all processing with ImageMagick and&#xA;Ghostscript. Zsh and GNU parallel were also my friends.&lt;/p&gt;&#xA;&lt;h4 id=&#34;convert-and-chop-4-sides&#34;&gt;Convert and Chop 4 sides&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;convert input.png -crop +300+300 -crop -300-300 output.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;convert-and-rotate&#34;&gt;Convert and Rotate&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;convert input.png -rotate -90 -page A4 output.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;convert-many-files-in-parallel&#34;&gt;Convert many files in parallel&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;find . -name &lt;span class=&#34;s1&#34;&gt;&amp;#39;*.jpg&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; parallel convert &lt;span class=&#34;o&#34;&gt;{}&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;.&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;merge-and-optimize&#34;&gt;Merge and optimize&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gs -dBATCH -dNOPAUSE -q -sDEVICE&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;pdfwrite -dPDFSETTINGS&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;/ebook -sOutputFile&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;merged.pdf &lt;span class=&#34;se&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;one.pdf two.pdf three.pdf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Result file will be optimized because of &lt;code&gt;-dPDFSETTINGS=/ebook&lt;/code&gt;.&lt;/p&gt;&#xA;</content:encoded>
			</item>
			<item>
				<title>Malaysian fuel prices and open data</title>
				<link>https://xie.oskarsh.ru/post/dosm/</link>
				<pubDate>Sat, 29 Jul 2023 00:19:39 +0700</pubDate>
				<guid>https://xie.oskarsh.ru/post/dosm/</guid>
				<description>&lt;p&gt;I wanted to write a blog post about Malaysian fuel prices. RON95 petrol and diesel are&#xA;subsidised by the government. Compare these graphs.&lt;/p&gt;&#xA;&lt;h4 id=&#34;diesel-price-per-litre-in-ringgits&#34;&gt;Diesel price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;diesel.webp&#34; alt=&#34;&#34; title=&#34;Diesel price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;h4 id=&#34;ron95-petrol-price-per-litre-in-ringgits&#34;&gt;RON95 petrol price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;ron95.webp&#34; alt=&#34;&#34; title=&#34;RON95 petrol price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;h4 id=&#34;ron97-petrol-price-per-litre-in-ringgits&#34;&gt;RON97 petrol price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;ron97.webp&#34; alt=&#34;&#34; title=&#34;RON97 price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;These subsidies are also a reason why it&amp;rsquo;s illegal to fuel a car with RON95 if you&amp;rsquo;re a&#xA;foreigner.&lt;/p&gt;</description>
				<content:encoded>&lt;p&gt;I wanted to write a blog post about Malaysian fuel prices. RON95 petrol and diesel are&#xA;subsidised by the government. Compare these graphs.&lt;/p&gt;&#xA;&lt;h4 id=&#34;diesel-price-per-litre-in-ringgits&#34;&gt;Diesel price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;diesel.webp&#34; alt=&#34;&#34; title=&#34;Diesel price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;h4 id=&#34;ron95-petrol-price-per-litre-in-ringgits&#34;&gt;RON95 petrol price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;ron95.webp&#34; alt=&#34;&#34; title=&#34;RON95 petrol price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;h4 id=&#34;ron97-petrol-price-per-litre-in-ringgits&#34;&gt;RON97 petrol price per litre, in ringgits&lt;/h4&gt;&#xA;&lt;p&gt;&lt;img src=&#34;ron97.webp&#34; alt=&#34;&#34; title=&#34;RON97 price graph&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;These subsidies are also a reason why it&amp;rsquo;s illegal to fuel a car with RON95 if you&amp;rsquo;re a&#xA;foreigner.&lt;/p&gt;&#xA;&lt;p&gt;Did you like the graphs above?&lt;/p&gt;&#xA;&lt;p&gt;This data and these graphs are provided by the &lt;a href=&#34;https://open.dosm.gov.my/&#34;&gt;OpenDOSM project&lt;/a&gt;. DOSM is&#xA;Department of Statistics Malaysia. The website is a collection of DOSM&amp;rsquo;s data published by&#xA;Creative Commons licenses. &lt;a href=&#34;https://github.com/dosm-malaysia&#34;&gt;Frontend and Backend repositories&lt;/a&gt; are also published&#xA;as Free Software!&lt;/p&gt;&#xA;&lt;p&gt;And I like it. Researchers are funded by taxpayers. Taxpayers get their data freely.&lt;/p&gt;&#xA;</content:encoded>
			</item>
			<item>
				<title>Git Symbolic Links in Windows</title>
				<link>https://xie.oskarsh.ru/post/git-symbolic-links-in-windows/</link>
				<pubDate>Fri, 30 Jun 2023 02:34:18 +0800</pubDate>
				<guid>https://xie.oskarsh.ru/post/git-symbolic-links-in-windows/</guid>
				<description>&lt;p&gt;Today I learned: &lt;code&gt;git clone&lt;/code&gt; breaks symlinks on Windows system.&lt;/p&gt;&#xA;&lt;p&gt;Thankfully, I used symlinks in my project by mistake and I could delete them. On internet&#xA;there&amp;rsquo;re people who rely on a bunch of symlinks and search for hacks to workaround msysgit&#xA;issue.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201&#34;&gt;https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201&lt;/a&gt;&lt;/p&gt;</description>
				<content:encoded>&lt;p&gt;Today I learned: &lt;code&gt;git clone&lt;/code&gt; breaks symlinks on Windows system.&lt;/p&gt;&#xA;&lt;p&gt;Thankfully, I used symlinks in my project by mistake and I could delete them. On internet&#xA;there&amp;rsquo;re people who rely on a bunch of symlinks and search for hacks to workaround msysgit&#xA;issue.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201&#34;&gt;https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201&lt;/a&gt;&lt;/p&gt;&#xA;</content:encoded>
			</item>
	</channel>
</rss>
