teleren/devto huggingface dataset:
Line-Height... lineheight... line-height
Tags: lineheight, css, javascript
Published: 2018-09-25 19:20:57

---
title: Line-Height... lineheight... line-height
published: true
tags: line-height,css,js
canonical_url: http://designfrontier.net/line-height-line-height-line-height
---

Consider this a Public Service Agreement: There is a bug loose in the internet. It’s a subtle bug but so far every browser I have checked has some variation of this bug.

So what is this bug? Will it eat my website? Does it carry diseases? Is it a virus?! Will there be zombies?

Ok, calm down. Let me answer those in reverse order (because it’s more fun that way).

There will be no zombies as a result of this bug. I promise. We’re pretty sure about that.

It is not a virus. There are many viruses on the internet but this is not one of them.

It does not seem capable of carrying diseases.

Generally it will not eat your website, though it probably lives there without you knowing about it. This is generally not an issue, though if your website develops odd line spacing, spots, blurry vision, delusions of grandeur, ugly layouts, bad design in general, or starts acting strangely, we suggest that you consult with a professional. Also, if your website starts talking to you please seek proper medical or professional attention.

The bug is embedded in the way that various browsers deal with math, and line-height in specific. For an example go look at this link in as many browsers as you can get your hands on: [http://jsfiddle.net/95cqM/1/](http://jsfiddle.net/95cqM/1/)

The line-height value changes based on whether it is specified merely as a ratio or using the em unit of measure, which is a ratio. All browsers except Firefox demonstrate this part of the bug, returning different values for the two which are theoretically equivalent.

The second aspect of the bug is that there really shouldn’t be a way to specify fractional pixels. The concept of fractional pixels doesn’t actually exist. A pixel size is an integer, no decimals allowed because a computer doesn’t know how to draw half a pixel. At least as far as I know…

Realistically this is more of an interesting discovery, and less of a problem. Unless you are doing some calculation based on line-height in javascript you won’t see any weird behavior as a result of it. If you are… well you’re going to need to account for this weirdness in your calculations. Welcome to the Internet!
Javaで短いFizzBuzz
Tags: java, fizzbuzz
Published: 2013-08-04 05:47:00

---
title: Javaで短いFizzBuzz
published: true
tags: Java, FizzBuzz
date: 20130804T05:47Z
canonical_url: https://qiita.com/shiena/items/5c8bced35ccc0bc8cf99
---
数年前に[Anarchy Golf](http://golf.shinh.org/p.rb?FizzBuzz#Java)に投稿したjavaのFizzBuzzです。
懐しくて公開しました。

```java:f.java
class f{public static void main(String[]a){for(int i=0;++i<101;)System.out.println((i%3<1?"Fizz":"")+(i%5<1?"Buzz":i%3<1?"":i));}}
```

更に短いコードはenumを使うようですが、Anarchy Golfではstderrをチェックされるのでテストを通りませんでした。

```java:f.java
enum f{a;{for(int i=0;++i<101;)System.out.println((i%3<1?"Fizz":"")+(i%5<1?"Buzz":i%3<1?"":i));}}
```

Javaは文法の制約が厳しめなので他の言語ほど短くするのは難しくないと思います。
Simple prototype inheritance in JavaScript
Tags: oop, javascript
Published: 2013-07-31 15:51:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Simple prototype inheritance in JavaScript
slug: simple-prototype-inheritance-in-javascript
date: 2013-07-31 15:51
tags: 
 - oop
 - javascript
---
This post is more of a snippet than an in-depth post; something for the future when I stop doing JS and probably forget everything. I do actually think my brain is like Homer's, whenever I learn something new, the old stuff seems to leak out!

The snippet below is simple JavaScript prototype inheritance. Being a .NET person, it seems a bit strange at first, but really it's just a chain of base classes known as prototypes that link right back to the object. I wanted to get an idea of how regular ol' js works without using any of the supposedly great libraries out there such as [base.js](https://code.google.com/p/base2/) and [John Resig's Simple JavaScript Inheritance](http://ejohn.org/blog/simple-javascript-inheritance/).

    var Base = function() {  
      this.printString = function(string) {
        console.log(string);
      }
    };

    var Ext = function() {
      this.printMessage = function() {
        this.printString("Hello, testing!");
      }
    };

    Ext.prototype = new Base();

    var ext = new Ext();
    ext.printString("test!"); // calls prototype method from Base
    ext.printMessage();       // calls method from Ext

Quite self-explanatory, hopefully I will get some time to delve more into this. Expect posts if I do!
Override selection style with CSS
Tags: css, design
Published: 2013-07-30 14:39:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Override selection style with CSS
slug: override-selection-style-with-css
date: 2013-07-30 14:39
tags: 
 - css
 - design
---
You may have noticed that certain designs, such as the [amazing SI Digital website](http://sidigital.co/), have a custom style for the selection of text. When used properly, to match your designs main colour for example, this can give a really nice and polished feel.

It's really quite simple to implement as well. You can change the foreground `color` as well as the `background` color like so:

    ::selection { color: white; background: #5AB54A; }
    ::-moz-selection { color: white; background: #5AB54A; }

Not all properties can be set using `::selection` though. Properties that *can* be set are `color`, `background`, `background-color` and `text-shadow`. Though according to [this article](https://developer.mozilla.org/en-US/docs/Web/CSS/::selection), `background-image` is ignored. Setting the background to use an image is also ignored, and it appears that opacity is also set and unable to be changed.

Still, this is a very nice feature for modern browsers, and can really add that finishing touch to your design.
RhodeCodeでPull Requestするとエラーになるのでアドホックパッチ
Tags: rhodecode
Published: 2013-07-29 03:38:00

---
title: RhodeCodeでPull Requestするとエラーになるのでアドホックパッチ
published: true
tags: RhodeCode
date: 20130729T03:38Z
canonical_url: https://qiita.com/shiena/items/390048157622befb2bce
---
[RhodeCode](http://rhodecode.org/)でPull Requestするとエラーが起きて、以下のログが出力されました。
`UnicodeEncodeError`なのでpythonで定番のstrとunicodeを混ぜてしまったパターンです。
このとき`production.ini`で`lang=ja`を設定して日本語表示にしていたのですが、もしやと思い`lang=en`にするとPull Requestは成功しました。

```text:
[error] 2013-07-26 00:55:06.550 ERROR [rhodecode.controllers.pullrequests] Traceback (most recent call last):
[error]   File "/home/rhodecode/rhodecode-venv/lib/python2.7/site-packages/rhodecode/controllers/pullrequests.py", line 340, in create
[error]     other_ref, revisions, reviewers, title, description
[error]   File "/home/rhodecode/rhodecode-venv/lib/python2.7/site-packages/rhodecode/model/pull_request.py", line 87, in create
[error]     pull_request=new
[error]   File "/home/rhodecode/rhodecode-venv/lib/python2.7/site-packages/rhodecode/model/changeset_status.py", line 135, in set_status
[error]     text='Auto status change to %s' % (ChangesetStatus.get_status_lbl(status)),
[error]   File "/home/rhodecode/rhodecode-venv/lib/python2.7/site-packages/pylons/i18n/translation.py", line 42, in __str__
[error]     return str(self.eval())
[error] UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
```

Tracebackであやしそうな`ChangesetStatus.get_status_lbl(status)`の処理を追うとgettextを使っているので当たりです。
`lang=en`ではASCIIコードの範囲内なのでstrでも動くのですが、他の言語ではASCIIコードの範囲外になるので予想通りのパターンです。
以下のパッチのようにフォーマット文字列をunicodeにすると運良くPull Requestが動くようになりました。

```diff:rhodecode/model/changeset_status.py
--- rhodecode/model/changeset_status.py.orig    2013-06-16 12:58:07.000000000 +0900
+++ rhodecode/model/changeset_status.py 2013-07-26 01:39:31.683912780 +0900
@@ -132,7 +132,7 @@
         if not comment:
             from rhodecode.model.comment import ChangesetCommentsModel
             comment = ChangesetCommentsModel().create(
-                text='Auto status change to %s' % (ChangesetStatus.get_status_lbl(status)),
+                text=u'Auto status change to %s' % (ChangesetStatus.get_status_lbl(status)),
                 repo=repo,
                 user=user,
                 pull_request=pull_request,

```

※追記
本家にバグ報告したらさくっと[取り込まれました](https://secure.rhodecode.org/rhodecode/changeset/7baea802f739c2af885e98865c1a5ad8ccfeab10)。
次回以降のバージョンでリリースされると思います。
Excel SUM/COUNT based on background colour
Tags: excel, vba
Published: 2013-07-24 11:27:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Excel SUM/COUNT based on background colour
slug: excel-sum-count-based-on-background-colour
date: 2013-07-24 11:27
tags: 
 - excel
 - vba
---
Today I have had to use VB. It's been seven or eight years since I last touched it, and today it's only to briefly complete a solution in Excel. I miss my curly braces. 

I've been asked how to calculate a `SUM()` based on cell background colour, and it looks like there isn't anything built in for this. My [StackOverflow question](http://stackoverflow.com/questions/17829816/how-can-i-find-sum-of-highlighted-cells) didn't exactly bring any great ideas, so it looks like a VBA script was my only option.

![Example](http://i.stack.imgur.com/Ii27n.png)

The following snippet -- inserted by pressing Alt + F11, then going to Insert and Module -- will `SUM()` based on the background colour of the cell passed in the first argument, the second argument being the range:

    Function SUMCLR(rColor As Range, rRange As Range)
        Dim rCell As Range
        Dim lCol As Long
        Dim vResult
        lCol = rColor.Interior.ColorIndex
        For Each rCell In rRange
            If rCell.Interior.ColorIndex = lCol Then
                vResult = WorksheetFunction.SUM(rCell, vResult)
            End If
        Next rCell
        SUMCLR = vResult
    End Function

This next snippet performs a count, rather than a sum operation:

    Function COUNTCLR(rColor As Range, rRange As Range)
        Dim rCell As Range
        Dim lCol As Long
        Dim vResult
        lCol = rColor.Interior.ColorIndex
        For Each rCell In rRange
            If rCell.Interior.ColorIndex = lCol Then
                vResult = 1 + vResult
            End If
        Next rCell
        COUNTCLR = vResult
    End Function

And then in the cells, just use the formula for example `=SUMCLR(A1, B1:B10)` and `=COUNTCLR(A1, B1:B10)`.
vimでコマンドラインウインドウを使わないのはもったいない
Tags: vim
Published: 2013-07-23 13:29:00

---
title: vimでコマンドラインウインドウを使わないのはもったいない
published: true
tags: Vim
date: 20130723T13:29Z
canonical_url: https://qiita.com/shiena/items/d73ca1dd9d2855c98829
---
# コマンドラインウインドウって何？

`:`で実行したExコマンドや`/`と`?`で検索した履歴をvimのウインドウに表示したり再実行できる機能です。
コマンドモードは1行しかないので履歴を辿るのに視認性が悪かったり、カーソル移動が矢印キーなので面倒だったりしますが、コマンドラインウインドウではウインドウ内に数行分の履歴を表示したり、vimのカーソル移動やコマンドを実行できるので、使いやすくなっています。

*※ここで言うウインドウはWindowsやMacのウインドウではなく、vimのウインドウです。*

# どうやって使うの？

## 履歴を表示、実行する

Exコマンドの場合、`:`の代わりに`q:`を入力するとvimのウインドウが分割されて下側にコマンド履歴が表示されます。
vimを終了する`:q`と間違えて入力したことがある人は見覚えがないでしょうか？

![コマンドラインウインドウ](https://dev-to-uploads.s3.amazonaws.com/i/est9rk2qz09roviw7rtd.png)

ここで`Enter`を入力するとカーソルがある行のコマンドが実行されます。もちろん編集もできます。

また、履歴から前方検索したい場合は`/`の代わりに`q/`、後方検索の場合は`?`の代わりに`q?`を入力すると同様にコマンドラインウインドウが開きます。

## コマンドラインウインドウを閉じる

vimのウインドウなので`:q`で閉じます。

# その他の機能

## 履歴をvimのコマンドラインに送る

コマンドラインウインドウで`Ctrl-C`を入力するとカーソルがある行の履歴がコマンドラインに送られます。
コマンドラインに移動後、`Esc`や`Ctrl-C`で実行をキャンセルするとコマンドラインウインドウも一緒に閉じます。

## コマンドラインウインドウを開く別の方法

`:`や`/`、`?`でコマンドラインに移動後、`Ctrl-F`を入力するとコマンドラインウインドウが開きます。

# もっと詳しく

続きは`:help cmdwin`で
msysgitでSTATUS_ACCESS_VIOLATIONを解消する方法の1つ
Tags: windows, git
Published: 2013-07-22 06:31:00

---
title: msysgitでSTATUS_ACCESS_VIOLATIONを解消する方法の1つ
published: true
tags: Windows, Git
date: 20130722T06:31Z
canonical_url: https://qiita.com/shiena/items/de89dad3bfca33ce776b
---
# gitが動かない！
Windows7でmsysgitを使っていたところ、何かを境にしてSTATUS_ACCESS_VIOLATIONが起きるようになりgitを使えなくなりました。

＿人人人人人人人人＿
＞　突然のgit死亡　＜
￣Y^Y^Y^Y^Y^Y^Y￣

症状は[Fails with Exception: STATUS_ACCESS_VIOLATION](https://github.com/msysgit/msysgit/issues/25)と同じです。

# 試行錯誤の日々

藁にもすがる思いで何とか見付け出した解決方法を色々と試してみました。
結論を先に書くとどれもダメでした。

## cygwinやmsysと混ぜるな危険

msysgitのmsys-1.0.dllがcygwinやmsysのDLLと干渉することがあるらしいのですが、そもそも使ってないので他に原因があるようです。

## DLLをrebase

gitのrebaseコマンドではなく、msys-1.0.dllをロードするアドレスが他のDLLと干渉するため、rebaseコマンドでアドレスを変更する方法らしいです。
環境によって干渉しないアドレスが違い、一度DLLをロードするとrebaseしても再起動するまで反映されないので時間ばかり食われた挙句、諦めてしまいました。

## 新規アカウントで試す

システム自体に問題があるのか、アカウントの環境に問題があるのか切り分けるために新規アカウントで作ったのですが、こちらでは問題ありません。どうやらアカウントの環境に問題があるようです。

# やっと解決

何となく **TEMPフォルダのゴミファイルを削除したら** gitが動くようになりました！
もう意味が分かりません。msysgitってTEMPフォルダから何かロードしているのでしょうか？

何はともあれ動くようになったのですが、試行錯誤の数ヶ月の間に覚えたTortoiseHGが便利すぎて戻れなくなってしまいました。

※TEMPフォルダは環境変数`TEMP`や`TMP`が指すフォルダです。
Prevent scrolling of parent element with JavaScript
Tags: javascript, web, frontend
Published: 2020-05-04 15:24:37

---
title: Prevent scrolling of parent element with JavaScript
published: true
date: 2013-07-16 13:16:30 UTC
tags: javascript,web,frontend
canonical_url: 
---

In my current project, I was asked to avoid scrolling of the parent element, when reaching the end of the scroll of the inner element.

It sounds like a very simple task. Not when you want to implement it cross-browser. So, I searched a little and found[next example](https://www.inkling.com/read/javascript-definitive-guide-david-flanagan-6th/chapter-17/handling-mousewheel-events) from the book: “JavaScript: The Definitive Guide”. By the way, it’s a very good book to start with when you want to learn JavaScript basics.

So, based on this example[here is jsFiddle](http://jsfiddle.net/dima_k/5mPkB/1/) with my solution for a problem.

Enjoy

![javascript-book](https://cdn-images-1.medium.com/max/176/0*XZJQkYt4TbPLmWCO.jpg)

* * *
Mercurialで安全にパスワードを保存する
Tags: mercurial
Published: 2013-07-15 15:32:00

---
title: Mercurialで安全にパスワードを保存する
published: true
tags: Mercurial
date: 20130715T15:32Z
canonical_url: https://qiita.com/shiena/items/dd4f919f363ec6e2427e
---
Mercurialでパスワードを保存するには、以下のように記述する方法があります。

```sh:~/.hgrc
[auth]
example.com.prefix = https://example.com
example.com.user = xxxxxxx
example.com.password = xxxxxxx
```

ですが、生パスワードを記述するので安全とは言えません。
そこで[Mercurial-Keyring](https://bitbucket.org/Mekk/mercurial_keyring)拡張を使います。
以下のように、この拡張を有効にしてパスワード設定を削除しておくと、初回のみパスワード入力を要求されてパスワードデータデースに保存されます。
次回からはパスワードデータデースを利用するため安全にパスワードを保管できます。

```sh:~/.hgrc
[extensions]
mercurial_keyring = /path/to/mercurial_keyring.py

[auth]
example.com.prefix = https://example.com
example.com.user = xxxxxxx
```

Windows版のTortoiseHGはこの拡張が同梱されているので、以下の設定だけで有効にできます。

```sh:Mercurial.ini
[extensions]
mercurial_keyring =
```

その他、パスワードの保存先など詳しくは[TortoiseHg v1.0.0 documentation/8.5. Mercurial-Keyring](http://tortoisehg.bitbucket.org/manual/2.8-ja/extensions.html#mercurial-keyring)に記載されているので参考にしてください。
Natural box layout model
Tags: css
Published: 2013-07-15 12:58:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Natural box layout model
slug: natural-box-layout-model
date: 2013-07-15 12:58
tags: 
 - css
---
Unfortunately, browsers do not always implement the default CSS rules that we would like. One rule which should almost definitely be added to every browser ever is the following, applying border-box box-sizing to, well, everything.

    /* apply a natural box layout model to all elements */
    * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }

Thanks go to Paul Irish if I remember correctly.
Pass the Hash toolkit, Winexe and more.
Published: 2023-08-21 21:24:19

---
title: Pass the Hash toolkit, Winexe and more.
published: true
date: 2013-07-15 00:00:00 UTC
tags: 
canonical_url: https://www.kali.org/blog/pass-the-hash-toolkit-winexe-updates/
---

We’ve just pushed a bunch of packages, tools, and utilities to the main Kali repositories. These tools have been on the top of our wish list for a while and some of them were quite challenging to package. Before we start telling you of our packaging woes, here’s how to update your Kali installation and get the latest goodness from our repos:

```
apt-get update
apt-get dist-upgrade
apt-get install passing-the-hash unicornscan winexe
apt-get install unicornscan enum4linux polenum
apt-get install nfspy firmware-mod-kit wmis
# and if you haven't already:
apt-get install nipper-ng jsql oclgausscrack ghost-phisher uniscan
apt-get install lbd automater arachni bully inguma sslsplit dumpzilla
apt-get install owasp-mantra-ff recon-ng ridenum regripper jd-gui

```

### Pass The Hash Toolkit

We have \*finally\* finished packaging the [Pass the Hash Toolkit](https://code.google.com/archive/p/passing-the-hash/downloads) in an elegant and intelligent way, thanks to samba4. Samba 4 is architectured differently than previous versions and many parts of the core functionality have been moved into libraries. This made it possible for us to easily override a couple of functions in those libraries with the help of the dynamic loader (using LD\_PRELOAD) and saved us the need to recompile a patched samba in order to introduce the PTH tookit to Kali. All PTH tools and utilities have a “ **pth-** ” prefix.

### Winexe

Winexe (also with PTH capabilities) was also challenging to get running in Kali due to [mysterious segfaults](https://sourceforge.net/p/winexe/bugs/21/) in the application on 32 bit Kali systems. Fortunately, those issues were solved and the latest Winexe is now available in the Kali repositories.

### Kali Linux Release at DEF CON 21

We will be releasing a bugfix rollup of Kali Linux during the BlackHat and DEF CON security conferences this year - all these tool additions and updates will be available in the upcoming release. To all conference goers, see you there!
IntelliJとGradleとVCSではまったこと
Tags: git, mercurial, intellij, gradle
Published: 2013-07-14 16:02:00

---
title: IntelliJとGradleとVCSではまったこと
published: true
tags: Git, Mercurial, IntelliJ, gradle
date: 20130714T16:02Z
canonical_url: https://qiita.com/shiena/items/8c8dbbd51dd4566125c0
---
IntelliJでGradleとVCSを使うときに以下の構成に当てはまると起こる問題です。

* Gradleの構成がフラットなスタイルのマルチプロジェクトであること
* VCSにGitもしくはMercurialを使っていること

フラットなスタイルについては前に投稿した[Gradleでマルチプロジェクト](http://qiita.com/shiena/items/371fe817c8fb6be2bb1e)をご覧下さい。

この構成にしていると各モジュールをリポジトリのルートディレクトリとして扱うらしく、
変更したファイルの検出やAnnotateでコマンドの実行に失敗したりします。
この困った状況を解消するために、以下の手順でリポジトリのルートディレクトリを設定します。

1. `Settings` -> `Version Control`を開く
1. `Directory`欄が`<Project>`の`VCS`欄を`<none>`にする
1. `+`ボタンで`Directory`欄にリポジトリのルートディレクトリを追加して、`VCS`欄を`Git`もしくは`Mercurial`の使っている方を設定する

以上の設定でVCSの機能が正しく動くようになります。
Git workflow scripts
Tags: productivity, bash, git
Published: 2013-07-11 15:37:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Git workflow scripts
slug: git-workflow-scripts
date: 2013-07-11 15:37
tags: 
 - productivity
 - bash
 - git
---
The following are a couple of general purpose scripts which will help you to work quicker with Git. Put these in your bin folder, so either `/home/user/bin` or `C:\Users\Username\bin` depending on your OS. Remember if it's nix, `chmod +x` them.

`ga` - Git add script:

    #!/bin/sh
    git add -A

`gs` - Git status script:

    #!/bin/sh
    git status

`gpull` - Git pull script (origin master):

    #!/bin/sh
    git pull origin master

`gpush` - Git push script (origin master):

    #!/bin/sh
    git push origin master

`gc` - Git commit script:

    #!/bin/sh
    read -p "Commit msg: " desc
    git commit -m "$desc"

`gfull` - Git add, status, commit (with msg) and push (origin master) script.

    #!/bin/sh
    git add -A
    git status
    read -p "Commit msg: " desc
    git commit -m "$desc"
    git push origin master

I may post more if I come up with anything more intricate, but for now, these can save a lot of time.

If you have any scripts you use often, be sure to share them!
Fix jagged fonts in Chrome/WebKit
Tags: webkit, chrome, css
Published: 2013-07-10 14:50:00

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/y9hxcwi5y92j6zfcxbjx.jpg
title: Fix jagged fonts in Chrome/WebKit
slug: fix-jagged-fonts-in-chrome-webkit
date: 2013-07-10 14:50
tags: 
 - webkit
 - chrome
 - css
---
Just a quick post today, more of a reminder for myself than anything. The following is a great way to fix jagged fonts when using font kits with Chrome/WebKit based browsers. 

The following is what you'd expect to see when defining a font face:

    @font-face {
      font-family: 'FontName';
      src: url('../fonts/FontName.eot');
      src: url('../fonts/FontName.eot?#iefix') format('embedded-opentype'),
           url('../fonts/FontName.woff') format('woff'),
           url('../fonts/FontName.ttf') format('truetype'),
           url('../fonts/FontName.svg') format('svg');
      font-weight: normal;
      font-style: normal;
    }

Well, [apparently Chrome uses the SVG and does not like it coming last](http://www.adtrak.co.uk/blog/font-face-chrome-rendering/).

Append this to your CSS and you'll get much better results:

    @media screen and (-webkit-min-device-pixel-ratio:0) {
      @font-face {
        font-family: 'FontName';
        src: url('../fonts/FontName.svg') format('svg');
      }
    }

Without fix, and with the fix:

![Fix jagged fonts in Chrome/WebKit](http://i.imgur.com/Ubxkcod.png)
Hello World
Tags: crystallang
Published: 2013-07-10 00:00:00

---
title: Hello World
description: The famous Hello World program written in different ways in Crystal
published: true
tags: crystal-lang
canonical_url: https://crystal-lang.org/2013/07/10/hello-world.html
date: July 10th, 2013
---

_This blogpost was originally posted by [@asterite](https://github.com/asterite) and [@waj](https://gihtub.com/waj) on [the official Crystal Blog](https://crystal-lang.org/2013/07/10/hello-world.html)_

This is the simplest way to write the Hello World program in Crystal:

```
puts "Hello World"
```

But if you feel like it, you can also use some object oriented programming:

```
class Greeter
  def initialize(@name : String )
  end

  def salute
    puts "Hello #{@name}!"
  end
end

g = Greeter.new("world")
g.salute
```

Or maybe with blocks:

```
"Hello world".each_char do |char|
  print char
end
print '\n'
```

Each alternative might have a different performance, but luckily all of them are pretty expressive.

Ok, but what's the purpose of learning a language if we cannot run the damn thing? Let's see how we do this with Crystal (and let's assume you already have it [installed](https://crystal-lang.org/docs/installation/index.html)).

First create a file `hello.cr` containing your preferred choice of the previous examples.
Then type in the console:

```
$ bin/crystal hello.cr
$ ./hello
Hello World
$
```

The compiled output is a standalone executable without any specific runtime dependency. Neat! Isn't it?