This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <unistd.h> | |
int main(void) { | |
struct sockaddr_in server_address; /* address of the server */ | |
int client_socket; /* FD of socket to connect with servers */ |
This file contains 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
FROM elixir:1.10.4 | |
## | |
# Install system dependencies & tooling | |
## | |
RUN apt-get update | |
RUN apt-get -y upgrade | |
RUN apt-get install -y bash curl apt-utils build-essential inotify-tools |
This file contains 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
/* | |
* 1. Create a sample table to store our bookings: | |
*/ | |
> CREATE TABLE bookings (id INT, scheduled_date DATE, start_time TIMESTAMP, end_time TIMESTAMP, timezone_id VARCHAR(40)) | |
> \d bookings | |
-- +----------------+-----------------------------+-------------+ | |
-- | Column | Type | Modifiers | | |
-- |----------------+-----------------------------+-------------| |
This file contains 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
## | |
# Implementation | |
## | |
# config/config.exs | |
config :my_app, :kv_store_adapter, KVStore | |
defmodule KVStore do | |
#... | |
end |
This file contains 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
# Configuration for Alacritty, the GPU enhanced terminal emulator. | |
# Any items in the `env` entry below will be added as | |
# environment variables. Some entries may override variables | |
# set by alacritty itself. | |
# env: | |
# TERM variable | |
# | |
# This value is used to set the `$TERM` environment variable for | |
# each instance of Alacritty. If it is not present, alacritty will |
This file contains 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
# An usual class is a subclass of object | |
class Human(object): | |
# Defining class variables | |
species = "H. Sapiens" | |
def __init__(self, first_name, last_name): | |
# Assign instance variables (also called attributes): | |
self.__internal = "secret" # Private attribute (externally accessed via: human._Human_internal) | |
self.first_name = first_name # Public attribute (externally accessed via human.first_name) | |
self.last_name = last_name # Since last_name has not a getter/setter below |
This file contains 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
type Query { | |
allPersons(last: Int): [Person!]! | |
} | |
type Mutation { | |
createPerson(name: String!, age: Int!): Person! | |
} | |
type Subscription { | |
newPerson: Person! |
This file contains 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 CreateFoo < ActiveRecord::Migration[5.0] | |
def change | |
create_table(:foos, force: true) do |t| | |
t.text :message, null: false | |
t.datetime :created_at, null: false | |
end | |
end | |
end |
This file contains 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
# Body-recursive | |
# | |
# Note: "+" is actually the last call, not calculate/1. | |
defmodule Fibonacci do | |
def calculate(x) when x <= 2, do: 1 | |
def calculate(x), do: calculate(x - 1) + calculate(x - 2) | |
end | |
# Tail-recursive (Tail Call Optimization) | |
# |
This file contains 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
FROM elixir:1.4.2 | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV HOME=/opt/app/ TERM=xterm | |
# Install Hex+Rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
WORKDIR /opt/app |
NewerOlder