<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kusnadin Ali  on Medium]]></title>
        <description><![CDATA[Stories by Kusnadin Ali  on Medium]]></description>
        <link>https://medium.com/@kusnadin.ali.12?source=rss-d60985a17786------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6prpM-yq9uXcVilF</url>
            <title>Stories by Kusnadin Ali  on Medium</title>
            <link>https://medium.com/@kusnadin.ali.12?source=rss-d60985a17786------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 15:38:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kusnadin.ali.12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Does 'A' Print 65 in Go? ]]></title>
            <link>https://medium.com/@kusnadin.ali.12/why-does-a-print-65-in-go-a13d517774aa?source=rss-d60985a17786------2</link>
            <guid isPermaLink="false">https://medium.com/p/a13d517774aa</guid>
            <category><![CDATA[unicode]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[learning-from-scratch]]></category>
            <category><![CDATA[go-language]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kusnadin Ali ]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 05:32:06 GMT</pubDate>
            <atom:updated>2026-02-15T05:32:06.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*VCJc9PDDHTJ8y-o93-sGvw.jpeg" /></figure><p>When I first started learning Go, I was surprised by something simple. In Java, a character like &#39;A&#39; clearly behaves like a character.</p><pre>fmt.Println(&#39;A&#39;)</pre><p>The output was not A.</p><p>It was:</p><pre>65</pre><p>Why? 😕</p><h3>🧠 &#39;A&#39; in Go Is Not a String</h3><p>In Go, single quotes (&#39; &#39;) are not for strings.</p><p>They represent a <strong>rune </strong>and in Go is simply an alias for <strong>int32</strong>.</p><p>Conceptually, a rune represents a <strong>Unicode code point</strong>.</p><p>So when we write:</p><pre>fmt.Println(&#39;A&#39;)</pre><p>Is essentially the same as:</p><pre>fmt.Println(int32(65))</pre><p>That’s why it prints 65. 😉</p><h3>⚖️ What About Comparison?</h3><p>At first, I thought this compared two characters:</p><pre>&#39;a&#39; != &#39;b&#39;</pre><p>But what’s actually being compared are the numeric values:</p><ul><li>&#39;a&#39; → 97</li><li>&#39;b&#39; → 98</li></ul><p>So this is really:</p><pre>97 != 98</pre><p>Which obviously returns true.</p><p>Single quotes in Go mean numeric comparison at the Unicode level.</p><h3>🧵 String vs Rune</h3><p>Now here’s where things get more interesting.</p><p>If we use double quotes:</p><pre>&quot;A&quot;</pre><p>That is a <strong>string</strong>.</p><p>And in Go, a string is a <strong>sequence of bytes</strong>, encoded using UTF-8.</p><p>While:</p><pre>&#39;A&#39;</pre><p>Is a rune (a single Unicode code point / int32).</p><p>This difference becomes very important when dealing with string length or non-ASCII characters.</p><h3>📏 Why Is an Emoji Length 4?</h3><p>Consider this:</p><pre>fmt.Println(len(&quot;A&quot;))  // 1<br>fmt.Println(len(&quot;👍&quot;)) // 4</pre><p>Why does the emoji return 4?</p><p>Because len() in Go counts <strong>bytes</strong>, not characters.</p><ul><li>&quot;A&quot; uses 1 byte in UTF-8</li><li>&quot;👍&quot; uses 4 bytes in UTF-8</li></ul><p>So:</p><pre>len(&quot;👍&quot;) // 4</pre><p>Means the emoji occupies <strong>4 bytes</strong> in memory.</p><h3>🔤 Counting Unicode Code Points</h3><p>If we want to count Unicode code points instead of bytes:</p><pre>fmt.Println(len([]rune(&quot;👍&quot;))) // 1</pre><p>Now it returns 1.</p><p>Because &quot;👍&quot; consists of exactly one Unicode code point.</p><h3>💣 Now Let’s Break Your Expectation</h3><p>What about this?</p><pre>fmt.Println(len([]rune(&quot;👍🏿&quot;)))</pre><p>You might expect 1.</p><p>But it returns<strong> 2</strong></p><p>Why? 🤔</p><p>Because &quot;👍🏿&quot; is actually made of two Unicode code points:</p><ul><li>👍 (thumbs up)</li><li>🟫 (skin tone modifier)</li></ul><p>Visually, it looks like one emoji.</p><p>Technically, it’s two code points combined.</p><h3>🚨 Rune Literal Limitation</h3><p>If you try:</p><pre>emot := &#39;👍🏿&#39;</pre><p>You’ll get:</p><pre>too many characters in rune literal</pre><p>Because a rune can only hold <strong>one Unicode code point</strong>,<br> and &quot;👍🏿&quot; contains two.</p><h3>🧠 So Is<em> </em><em>len([]rune())</em> Reliable for Counting Characters?</h3><p>Not always.</p><p>There are actually three levels involved:</p><ol><li><strong>Byte</strong> → how data is stored in memory</li><li><strong>Rune (Unicode code point)</strong> → logical character unit</li><li><strong>Grapheme cluster</strong> → what humans perceive as a single character</li></ol><p>Go handles the first two natively.</p><p>But what humans see as “one character” may consist of multiple Unicode code points. 🤯</p><h3>✅ Counting What Users Actually See</h3><p>If you want to count characters the way users perceive them (grapheme clusters), you can use a library like:</p><pre>github.com/rivo/uniseg</pre><p>Example:</p><pre>uniseg.GraphemeClusterCount(&quot;👍🏿&quot;)</pre><p>This correctly returns:</p><pre>1</pre><p>Because it counts based on grapheme clusters, not just code points.</p><p>It’s a small detail, but it can be surprisingly confusing when you first learn Go 🤯.</p><p>And it reminded me that string handling is never as simple as it looks.</p><p>Fun little discovery from learning Go from scratch 🚀. Cheers 🍻.</p><p>Consider this:</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a13d517774aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement File Upload Queue Processing in NestJS, Angular 17, and BullMQ]]></title>
            <link>https://medium.com/@kusnadin.ali.12/how-to-implement-file-upload-queue-processing-in-nestjs-angular-17-and-bullmq-57abbf6833c6?source=rss-d60985a17786------2</link>
            <guid isPermaLink="false">https://medium.com/p/57abbf6833c6</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[bullmq]]></category>
            <category><![CDATA[file-upload]]></category>
            <dc:creator><![CDATA[Kusnadin Ali ]]></dc:creator>
            <pubDate>Thu, 04 Jul 2024 03:38:56 GMT</pubDate>
            <atom:updated>2024-07-04T03:38:56.758Z</atom:updated>
            <content:encoded><![CDATA[<p>Pada artikel ini, saya akan menjelaskan bagaimana cara mengimplementasikan proses antrian (queue processing) saat mengunggah file menggunakan NestJS dan Angular 17. Proses antrian ini memungkinkan pengguna untuk mengunggah file tanpa harus menunggu proses file diunggah selesai. BullMQ digunakan sebagai message broker untuk mengelola antrian.</p><p><strong>Persiapan Lingkungan (Env)</strong></p><ul><li>NestJS</li><li>Angular 17</li><li>PostgreSQL</li><li>BullMQ</li><li>Redis</li></ul><p><strong>Setup Database</strong></p><p>Sebelum memulai, persiapkan database dan tabelnya. Contoh kasus ini menggunakan database “school-db” yang berisi data siswa.</p><pre>CREATE TABLE public.siswa (<br>    id serial PRIMARY KEY,<br>    name varchar NOT NULL,<br>    age int NOT NULL<br>);</pre><p><strong>Pembuatan Backend</strong></p><ul><li>Mulai dengan membuat proyek NestJS baru dengan perintah nest new be-upload-file.</li><li>Konfigurasikan koneksi database PostgreSQL pada app.module.ts.</li></ul><pre>@Module({<br>  imports: [TypeOrmModule.forRoot({<br>    type: &#39;postgres&#39;,<br>    host: &#39;localhost&#39;,<br>    port: 5432,<br>    username: &#39;postgres&#39;,<br>    password: &#39;root&#39;,<br>    database: &#39;school-db&#39;,<br>    entities: [Siswa]<br>  }), SiswaModule],<br>  controllers: [AppController],<br>  providers: [AppService],<br>})<br>export class AppModule {}</pre><ul><li>Buat resource untuk entitas siswa dengan perintah nest generate resource siswa.</li><li>Definisikan entitas siswa pada folder siswa.</li></ul><pre>@Entity(&#39;siswa&#39;)<br>export class Siswa {<br>    @PrimaryGeneratedColumn()<br>    id: number;<br><br>    @Column()<br>    name: string;<br><br>    @Column()<br>    age: number;<br>}</pre><ul><li>Konfigurasikan siswa.module.ts untuk menggunakan BullMQ dengan instalasi library Bull: npm i @nestjs/bull.</li></ul><pre>@Module({<br>  imports: [TypeOrmModule.forFeature([Siswa]),<br>    BullModule.forRoot({<br>      redis: {<br>        host: &#39;localhost&#39;,<br>        port: 6379<br>      },<br>    }),<br>    BullModule.registerQueue({<br>      name: &#39;siswa&#39;<br>    })],<br>  controllers: [SiswaController],<br>  providers: [SiswaService, UploadProcessor],<br>})<br>export class SiswaModule {}</pre><ul><li>Instal @nestjs/platform-express dan @types/multer untuk mengelola unggahan file.</li><li>Tambahkan metode pada siswa.controller untuk mengelola unggahan file.</li></ul><pre>@Post(&#39;/upload&#39;)<br>@UseInterceptors(FileInterceptor(&#39;csv&#39;, {<br>  storage: diskStorage({<br>    destination: &#39;./csv&#39;,<br>    filename: (req, file, cb) =&gt; {<br>      const randomName = Array(32).fill(null).map(() =&gt; (Math.round(Math.random() * 16)).toString(16)).join(&#39;&#39;);<br>      cb(null, `${randomName}${extname(file.originalname)}`);<br>    }<br>  })<br>}))<br>async uploadFile(@UploadedFile() file) {<br>  return this.siswaService.upload(file);<br>}</pre><ul><li>Implementasikan siswa.service untuk memproses file yang diunggah.</li></ul><pre>@Injectable()<br>export class SiswaService {<br>  constructor(<br>    @InjectQueue(&#39;siswa&#39;) private readonly siswaQueue: Queue<br>  ){}<br><br>  async upload(file) {<br>    await this.siswaQueue.add(&#39;upload&#39;, { file: file });<br>    return new ResponseDto(&#39;Success&#39;, null);<br>  }<br>}</pre><ul><li>Buat UploadProcessor untuk mengkonsumsi pesan yang dikirim oleh Bull dari Redis.</li></ul><pre>@Processor(&#39;siswa&#39;)<br>export class UploadProcessor {<br>  constructor(<br>    @InjectRepository(Siswa) private siswaRepository: Repository&lt;Siswa&gt;<br>  ) {}<br><br>  @Process(&#39;upload&#39;)<br>  async handleCsvFiles(job: Job) {<br>    try {<br>      const csv = require(&#39;csvtojson&#39;);<br>      const csvFilePath = process.cwd() + &#39;/&#39; + job.data.file.path;<br>      const siswaArray = await csv({ delimiter: &#39;;&#39; }).fromFile(csvFilePath);<br><br>      await this.siswaRepository.save(siswaArray);<br>    } catch (error) {<br>      console.log(&#39;error &#39;, error);<br>    }<br>  }<br>}</pre><ul><li>Pastikan Redis berjalan, lalu jalankan backend dengan npm run start.</li></ul><p><strong>Create FrontEnd</strong></p><p>Selanjutnya, buat proyek baru Angular dengan menggunakan perintah ng new fe-upload-file.</p><p>Lalu, hapus isi dari app.component.html dan ubah menjadi seperti berikut:</p><pre>&lt;main class=&quot;main&quot;&gt;<br>  &lt;div class=&quot;navbar&quot;&gt;<br>    &lt;a [routerLink]=&quot;[&#39;&#39;]&quot;&gt;<br>      &lt;h4&gt;Siswa&lt;/h4&gt;<br>    &lt;/a&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;content&quot;&gt;<br>    &lt;router-outlet&gt;&lt;/router-outlet&gt;<br>  &lt;/div&gt;<br>&lt;/main&gt;</pre><p>Tambahkan CSS pada app.component.css:</p><pre>.navbar {<br>  margin-left: 3px;<br>  margin-right: 3px;<br>  padding: 5px 10px;<br>  background: #222222;<br>  color: #ffffff;<br>  border-radius: 10px;<br>}<br><br>a {<br>  color: #ffffff;<br>  text-decoration: none;<br>}<br><br>a:hover {<br>  color: #ffffff;<br>  text-decoration: none;<br>  cursor: pointer;<br>}<br><br>.content {<br>  margin: 10px;<br>}</pre><p>Tambahkan konfigurasi untuk menggunakan HttpClient sebagai library untuk REST API pada app.config.ts:</p><pre>export const appConfig: ApplicationConfig = {<br>  providers: [<br>    provideZoneChangeDetection({ eventCoalescing: true }),<br>    provideRouter(routes),<br>    provideClientHydration(),<br>    provideHttpClient(withFetch())<br>  ]<br>};</pre><p>Selanjutnya, buat komponen baru yang bernama home menggunakan perintah ng generate component home.</p><p>Ubah home.component.ts menjadi seperti berikut:</p><pre>import { Component } from &#39;@angular/core&#39;;<br>import { FormGroup, FormControl } from &#39;@angular/forms&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>@Component({<br>  selector: &#39;app-home&#39;,<br>  templateUrl: &#39;./home.component.html&#39;,<br>  styleUrls: [&#39;./home.component.css&#39;]<br>})<br>export class HomeComponent {<br>  formValue: FormGroup = new FormGroup({<br>    fileSource: new FormControl(),<br>    file: new FormControl()<br>  });<br><br>  url: string = &#39;http://localhost:3000/siswa&#39;;<br><br>  constructor(private readonly http: HttpClient) {}<br><br>  onFileChange(event: any) {<br>    if (event.target.files.length &gt; 0) {<br>      const csv = event.target.files[0];<br>      this.formValue.patchValue({ fileSource: csv });<br>    }<br>  }<br><br>  onSubmit() {<br>    const formData = new FormData();<br>    formData.append(&#39;csv&#39;, this.formValue.value.fileSource);<br>    this.http.post&lt;any&gt;(`${this.url}/upload`, formData).subscribe({<br>      next: () =&gt; {<br>        alert(&#39;Berhasil Upload Data&#39;);<br>      },<br>      error: () =&gt; {<br>        alert(&#39;Gagal upload data&#39;);<br>      }<br>    });<br>  }<br>}</pre><p>Ubah home.component.html menjadi seperti berikut:</p><pre>&lt;section&gt;<br>  &lt;h4&gt;Silakan pilih file CSV&lt;/h4&gt;<br>  &lt;form [formGroup]=&quot;formValue&quot; (submit)=&quot;onSubmit()&quot;&gt;<br>    &lt;input type=&quot;file&quot; id=&quot;csvFile&quot; name=&quot;csvFile&quot; accept=&quot;.csv&quot; formControlName=&quot;file&quot; (change)=&quot;onFileChange($event)&quot;&gt;&lt;br&gt;&lt;br&gt;<br>    &lt;button type=&quot;submit&quot; class=&quot;upload-button&quot;&gt;Upload&lt;/button&gt;<br>  &lt;/form&gt;<br>&lt;/section&gt;</pre><p>Tambahkan CSS pada home.component.css:</p><pre>section {<br>  text-align: center;<br>  margin: 20px;<br>}<br><br>input {<br>  border: 1px solid black;<br>  border-radius: 5px;<br>  padding: 5px;<br>  width: 20%;<br>}<br><br>.upload-button {<br>  padding: 10px 20px;<br>  background-color: #007bff;<br>  color: white;<br>  border: none;<br>  border-radius: 5px;<br>  cursor: pointer;<br>  transition: background-color 0.3s ease;<br>}<br><br>.upload-button:hover {<br>  background-color: #0056b3;<br>}</pre><p>Daftarkan route home pada app.routes.ts:</p><pre>import { Routes } from &#39;@angular/router&#39;;<br>import { HomeComponent } from &#39;./home/home.component&#39;;<br><br>export const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    component: HomeComponent,<br>    data: { title: &#39;Home&#39; }<br>  }<br>];</pre><p>Terakhir, jalankan frontend dengan perintah ng serve dan coba unggah file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjN6zl97PYjw1JI_NhqwPQ.png" /><figcaption>Tampilan Front end</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQk2TDNBUPlXdBb7AawvqQ.png" /><figcaption>Tampilan Berhasil Upload File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*JSuT1bCWpz4Z3SnIAdNO1g.png" /><figcaption>Tampilan data tersimpan</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57abbf6833c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>