Skip to content

Instantly share code, notes, and snippets.

Avatar

Mauricio Ribeiro MauricioRibeiroA

View GitHub Profile
@MauricioRibeiroA
MauricioRibeiroA / index.php
Created Aug 7, 2017 — forked from cosenary/index.php
Instagram API login (with sessions)
View index.php
<?php
require '../src/Instagram.php';
use MetzWeb\Instagram\Instagram;
session_start();
if (isset($_SESSION['access_token'])) {
// user authentication -> redirect to media
header('Location: success.php');
@MauricioRibeiroA
MauricioRibeiroA / diagonals.rb
Created Feb 16, 2017 — forked from EvilScott/diagonals.rb
Retrieve diagonals from array of arrays in Ruby
View diagonals.rb
class Array
def diagonals
[self, self.map(&:reverse)].inject([]) do |all_diags, matrix|
((-matrix.count + 1)..matrix.first.count).each do |offet_index|
diagonal = []
(matrix.count).times do |row_index|
col_index = offet_index + row_index
diagonal << matrix[row_index][col_index] if col_index >= 0
end
all_diags << diagonal.compact if diagonal.compact.count > 1
@MauricioRibeiroA
MauricioRibeiroA / diagonals.rb
Created Feb 16, 2017 — forked from EvilScott/diagonals.rb
Retrieve diagonals from array of arrays in Ruby
View diagonals.rb
class Array
def diagonals
[self, self.map(&:reverse)].inject([]) do |all_diags, matrix|
((-matrix.count + 1)..matrix.first.count).each do |offet_index|
diagonal = []
(matrix.count).times do |row_index|
col_index = offet_index + row_index
diagonal << matrix[row_index][col_index] if col_index >= 0
end
all_diags << diagonal.compact if diagonal.compact.count > 1