Skip to content

Instantly share code, notes, and snippets.

View vjdhama's full-sized avatar
🎯
Focusing

Vijay Dhama vjdhama

🎯
Focusing
View GitHub Profile
FROM postgres:9.5
ENV DEBIAN_FRONTEND=noninteractive
RUN set -xe && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
postgresql-9.5-partman

Keybase proof

I hereby claim:

  • I am vjdhama on github.
  • I am vjdhama (https://keybase.io/vjdhama) on keybase.
  • I have a public key ASDv34gD3fz7tI3TlpPsaHdvozAevMkunceqfDlAiEAPpQo

To claim this, I am signing this object:

@vjdhama
vjdhama / typed_arguments.cr
Created September 29, 2015 14:20
Typed args
def add(x : Int32, y : Int32)
x + y
end
@vjdhama
vjdhama / struct.cr
Last active September 29, 2015 13:24
structs
struct Vehicle
property speed
property color
def initialize(@speed, @color)
end
end
@vjdhama
vjdhama / overloads.cr
Created September 29, 2015 12:00
Method overloading
def add(x, y)
x + y
end
add(1, 2)
add("foo", "bar")
add("foo", 1)
@vjdhama
vjdhama / overloads_fix.cr
Created September 29, 2015 11:59
Method overloading
def add(x, y)
x + y
end
def add(x : String, y : Int32)
x + y.to_s
end
add(1, 2)
@vjdhama
vjdhama / conditionals.cr
Last active September 29, 2015 10:33
Union Types
if some_condition
name = "foo" #=> String
else
name = false #=> Boolean
end
@vjdhama
vjdhama / stderr.cr
Last active September 27, 2015 15:57
# Code
if Dir.exists?(name) || File.exists?(name)
STDERR.puts "file or directory #{name} already exists"
puts opts
exit 1
end
# Spec
$ make clean crystal
rm -rf .build
rm -rf ./doc
rm -rf src/llvm/ext/llvm_ext.o
c++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc ` --cxxflags`
/bin/bash: --cxxflags: command not found
src/llvm/ext/llvm_ext.cc:1:10: fatal error: 'llvm-c/Core.h' file not found
#include <llvm-c/Core.h>
^
1 error generated.
@vjdhama
vjdhama / foo.cr
Created September 23, 2015 09:22
# Returns a File::Stat object for the named file or raises
# `Errno::ENOENT` (See `File::Stat`)
#
# ```
# echo "foo" > foo
# File.stat("foo").size #=> 4
# File.stat("foo").mtime #=> 2015-09-23 06:24:19 UTC
# ```
def self.lstat(path)
if LibC.lstat(path, out stat) != 0