View gist:5bdd6bfacce20de6134ae6301a754c9d
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
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/logfile.log'); | |
$logger = new \Zend\Log\Logger(); | |
$logger->addWriter($writer); | |
$logger->info('message/var to log'); |
View codechallenge.go
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 "log" | |
func main() { | |
numbers := []int{23, 2, 4, 7, 2, 11} | |
find := 20 // should return true | |
// numbers := []int{1, 3, 5, 23, 2} | |
// find := 8 // should return true | |
//numbers := []int{1, 3, 5, 23, 2} |
View round.go
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 ( | |
"log" | |
"math" | |
) | |
func Round(val float64, roundOn float64, places int ) (newVal float64) { | |
var round float64 | |
pow := math.Pow(10, float64(places)) |
View FinderExample.Go
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 ( | |
"reflect" | |
"log" | |
) | |
type Part struct { | |
Id int | |
UPC string |
View sortBasedOnStructsProperty.go
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" | |
"sort" | |
) | |
type Person struct { | |
Name string | |
Weight int |
View CSVwriterExample
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
import ( | |
"../../web" | |
"bytes" | |
"encoding/csv" | |
} | |
func GenerateCSV(ctx *web.Context, args ...string) { | |
record := []string{"test1", "test2", "test3"} // just some test data to use for the wr.Writer() method below. |
View FindRanges.cs
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
public List<Range> findRanges(List<int> numbers) { | |
List<Range> ranges = new List<Range>(); // create a list of ranges that will eventually be populated. | |
numbers = numbers.OrderBy(x=>x).ToList<int>(); // order the list of numbers coming in. | |
int min = numbers.Min(); // get the smallest number | |
int max = numbers.Max(); // get the largest number | |
List<int> missingNumbers = new List<int>(); // create an empty list of missing numbers | |
int i = min; // create a counter for stepping through all the numbers starting with the smallest number | |
while (i < max) { // step through each possible number from min to max. | |
if (!numbers.Contains(i)) { // if the number doesnt exist from our list, its a missing number | |
// found a gap in the number (missing number) |
View Happpi_Getting_Started.php
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
<?php | |
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library. | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body> |
View Happpi_Getting_Started.php
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
<?php | |
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library. | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body> |
View example output
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
<Root xmlns="http://www.adventure-works.com"> | |
<Child3>1</Child3> | |
<Child3>2</Child3> | |
<Child3>3</Child3> | |
<Child4>4</Child4> | |
<Child5>5</Child5> | |
<Child5>6</Child5> | |
</Root> |