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
// Solve algorithm | |
func Solve(grid [N][N]int) (bool, [N][N]int) { | |
ch := make(chan [N][N]int) | |
pending, row, col := pendingPositions(grid) | |
if !pending { | |
fmt.Println("Solve calls:", count) | |
return false, grid | |
} |
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
func recursiveSolution(grid [N][N]int, ch chan [N][N]int) { | |
pending, row, col := pendingPositions(grid) | |
if !pending && CheckBoard(grid) { | |
ch <- grid | |
close(ch) | |
return | |
} | |
for i := 1; i <= 9; i++ { |
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
Gist for Atom Sync-Settings plugin |
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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
// ChannelsSolution uses a buffered channel with capacity of one | |
// in order to avoid data races from the go routines trying to increase | |
// the counter |
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
$(document).ready(function() { | |
function parseResponse(resultsContainer, data) { | |
console.log(data); | |
const resultsAmount = data.pages.length | |
$(resultsContainer).html(''); | |
if (resultsAmount > 0) { | |
$.each(data.pages, function(index, page) { | |
appendToResults(resultsContainer, page) | |
setResultsTitle(resultsAmount + " results found it for: " + data.input, 'green') |
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
require 'minitest/autorun' | |
# Problem | |
# https://softwareengineering.stackexchange.com/questions/153806/conflict-resolution-for-two-way-sync | |
# interface DB { | |
# String Get(String) | |
# void Set(String, String) | |
# []String Keys() | |
# |
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
# Violates SRP | |
class Invoice | |
def initialize(items, client) | |
@items = items | |
@client = client | |
@total = 0 | |
end | |
def generate |
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
# Violates LSP | |
class Company | |
def hire_people | |
expand_the_team | |
end | |
def open_new_location | |
create_a_new_office | |
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
# Violates ISP | |
class Airplane | |
def load_luggage | |
end | |
def load_fuel | |
end | |
def take_off | |
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
# Violates DIP | |
class InvoiceNotifier | |
def initialize(invoice) | |
@invoice = invoice | |
end | |
def mail_notification | |
InvoiceMailer.new.send(@invoice) | |
end |