| expression | JavaScript | CoffeeScript | LiveScript |
|---|---|---|---|
1 + 2 |
3 |
3 |
3 |
1 + "2" |
'12' |
'12' |
'12' |
"2" + 1 |
'21' |
'21' |
'21' |
1 * 2 |
2 |
2 |
2 |
"1" * 2 |
2 |
2 |
'11' |
1 * "2" |
2 |
2 |
'' |
1 / 2 |
0.5 |
0.5 |
0.5 |
"1" / 2 |
0.5 |
0.5 |
0.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foo = {foo: \foo} | |
| bar = -> | |
| console.log foo | |
| foo ?= {bar: \bar} | |
| return foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # only move files older than 5 days | |
| maxdate=$( date +%Y-%m-%d -d '5 days ago') | |
| # set source and destination folders unless set by env | |
| [ -z "$LOG_SOURCE" ] && LOG_SOURCE="/source/path" | |
| for file in $LOG_SOURCE/*.log.*; do | |
| # example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = exports = ObjectWithDefaultProperty; | |
| function ObjectWithDefaultProperty(properties, defaultValue) { | |
| return Proxy.create({ | |
| get: function get(proxy, name) { | |
| if (name in properties) { | |
| return properties[name]; | |
| } else { | |
| return defaultValue; | |
| } | |
| } |
Take this snippet, borrowed from the coffeescript changelog:
$ 'body'
.click (e) ->
$ '.box'
.fadeIn 'fast'
.addClass '.active'
.css 'background', 'white'Calling eh from vim
I use vim, and I occasionally write Elixir code.
Vim has built-in support for looking up documentation, keywordprg.
So since I wanted to be able to look up Elixir documentation from vim,
I wrote an elixir package called eh, which is available on hex.
To call eh from vim, add the following to your .vimrc:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| First off, install cowsay, and some PostgreSQL language extension, like [plsh](https://github.com/petere/plsh). | |
| Now, make sure to install the language extension in your database: | |
| $ psql | |
| = CREATE EXTENSION plsh; | |
| Now what you need is a function that takes some input and prints it using cowsay: | |
| =# CREATE FUNCTION cowsay (input text) RETURNS text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule GoogleBooks do | |
| use HTTPoison.Base | |
| @base_url "https://www.googleapis.com/books/v1/volumes?q=isbn:" | |
| def process_url(isbn13) do | |
| isbn = String.replace(isbn13, "-", "") | |
| @base_url <> isbn | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Cycle | |
| def initialize(array = []) | |
| @array = array | |
| end | |
| def call | |
| result = @array.first | |
| @array = @array.rotate | |
| result | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =ERROR REPORT==== 10-Aug-2015::21:33:01 === | |
| ** Generic server <0.876.0> terminating | |
| ** Last message in was {tcp,#Port<0.44223>, | |
| <<82,0,0,0,8,0,0,0,0,83,0,0,0,22,97,112,112,108, | |
| 105,99,97,116,105,111,110,95,110,97,109,101,0,0, | |
| 83,0,0,0,25,99,108,105,101,110,116,95,101,110, | |
| 99,111,100,105,110,103,0,85,84,70,56,0,83,0,0,0, | |
| 23,68,97,116,101,83,116,121,108,101,0,73,83,79, | |
| 44,32,77,68,89,0,83,0,0,0,25,105,110,116,101, | |
| 103,101,114,95,100,97,116,101,116,105,109,101, |