Skip to content

Instantly share code, notes, and snippets.

View joaofnds's full-sized avatar

João Fernandes joaofnds

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
struct node {
int rank;
char data;
struct node* parent;
};
struct node* create_node(char data);
#include <cstdio>
#include <iostream>
using namespace std;
inline int char_to_index(char c) { return c - 'a'; }
inline char index_to_char(int index) { return 'a' + index; }
int main(void) {
int vertices_number = 0, edges_number = 0, test_case_number = 5;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define TABLE_SIZE 100
#define WORD_SIZE 100
struct node {
char * key;
int value;
@joaofnds
joaofnds / dijkstra.cr
Last active August 15, 2017 16:42
Simple Dijkstra shortest path algorithm implementation using Crystal
struct Vertex
property id, edges
def initialize(@id : Int32)
@edges = Hash(Pointer(Vertex), Float64).new
end
end
def find(graph : Array(Pointer(Vertex)), start : Pointer(Vertex), end : Pointer(Vertex))
dist = {} of Pointer(Vertex) => Float64 # Distances
prev = {} of Pointer(Vertex) => Pointer(Vertex) # Path
<?php
//1) Preferred
"text {$array['name']} more text"; // associative single
"text $array[2] more text"; // numeric single
"text $object->name $object->price more text"; // property
//2) Valid alternatives
"text $array[name] more text"; // associative single
"text {$array[2]} more text"; // numeric single
@joaofnds
joaofnds / nginx.vhost
Last active November 5, 2016 15:07 — forked from vedovelli/nginx.vhost
server {
listen 80;
server_name CHANGEME.app;
root /var/www/vhosts/CHANGEME.app/public;
index index.html index.htm index.php;
charset utf-8;
location / {