Skip to content

Instantly share code, notes, and snippets.

View omarsancas's full-sized avatar

Omar Sánchez omarsancas

View GitHub Profile
@omarsancas
omarsancas / northwind.markdown
Created October 31, 2019 21:30 — forked from nicolewhite/northwind.markdown
MySQL to Neo4j

From SQL to Neo4j: Northwind

SQL Model

Neo4j Model

Get the SQL Dump

The SQL dump was stolen from here and imported into MySQL.

@omarsancas
omarsancas / neo4j_cypher_cheatsheet.md
Created October 31, 2019 21:26 — forked from DaniSancas/neo4j_cypher_cheatsheet.md
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
@omarsancas
omarsancas / GitCommitEmoji.md
Created June 13, 2019 15:46 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@omarsancas
omarsancas / add_auto_increment_to_int_single_pk.sql
Created November 5, 2018 20:56 — forked from carlosrobles/add_auto_increment_to_int_single_pk.sql
Add auto_increment to all the single PRIMARY KEY of type int of a database
DROP TABLE if exists temp;
CREATE TABLE temp (
`table` varchar(250) DEFAULT NULL,
`colum` varchar(250) DEFAULT NULL,
`type` varchar(250) DEFAULT NULL,
`number_of_PK` tinyint(2) DEFAULT NULL,
`alter` varchar(250) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
$ git clone git://example.com/myproject
$ cd myproject
$ git branch -a
$ git checkout -b experimental origin/experimental
@omarsancas
omarsancas / select_from_subquery.sql
Created May 4, 2018 17:16 — forked from stevenharman/select_from_subquery.sql
Using Arel/ActiveRecord to execute a subquery, including a SUM.
select fund_sums.total, fund_products.name
from (
select sum(allocation_amount) total, fund_product_id
from transactions
where transactions.investor_id = 490
group by fund_product_id
) fund_sums
left join fund_products on fund_sums.fund_product_id = fund_products.id
@omarsancas
omarsancas / select_from_subquery.sql
Created May 4, 2018 17:16 — forked from stevenharman/select_from_subquery.sql
Using Arel/ActiveRecord to execute a subquery, including a SUM.
select fund_sums.total, fund_products.name
from (
select sum(allocation_amount) total, fund_product_id
from transactions
where transactions.investor_id = 490
group by fund_product_id
) fund_sums
left join fund_products on fund_sums.fund_product_id = fund_products.id
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@omarsancas
omarsancas / sort.rb
Created June 7, 2017 03:40 — forked from aspyct/sort.rb
Sample implementation of quicksort, mergesort and binary search in ruby
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end
@omarsancas
omarsancas / The Technical Interview Cheat Sheet.md
Created June 7, 2017 03:40 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.