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
// array_unique is WAY TOO SLOW! This method is significantly faster. | |
array_flip(array_flip($arr)); | |
// If you need new keys generated use array_keys | |
array_keys(array_flip($arr)); |
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
if (!in_array(strtolower($input), array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'))){ | |
return false; | |
//or throw an exception | |
} |
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
mergeObjects: function(){ | |
var mergedObj = {}; | |
for (var i = 0, max=arguments.length; i !== max; i++) { | |
var obj = arguments[i]; | |
for (var key in obj) { | |
if( obj.hasOwnProperty(key) ) { | |
if( mergedObj[key] ) { | |
mergedObj[key] += obj[key] | |
} | |
else { |
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
var issue = 'solve this mess'; | |
var secretArgueTime = Math.floor(Math.random()*86400000); // If only it didn't actually boil down to this | |
filibuster = setInterval(function(){ | |
console.log('We must '+issue); | |
},500); | |
opposition = setInterval(function(){ | |
console.log('Never!'); | |
},500); |
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
{ | |
"Statement": [ | |
{ | |
"Sid": "PackerSecurityGroupAccess", | |
"Action": [ | |
"ec2:CreateSecurityGroup", | |
"ec2:DeleteSecurityGroup", | |
"ec2:DescribeSecurityGroups", | |
"ec2:AuthorizeSecurityGroupIngress", | |
"ec2:RevokeSecurityGroupIngress" |
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" | |
"math" | |
) | |
const( | |
ACCURACY_DELTA = 0.00000000000001 // Experiment with this value to see accuracy impact! | |
) |
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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
picData := make([][]uint8, dy) | |
for y := range picData { | |
picData[y] = make([]uint8, dx) |
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 ( | |
"code.google.com/p/go-tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
words := strings.Fields(s) |
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" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
var m1, m2 int | |
return func() int { | |
res := m1 + m2 |
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" | |
import "math/cmplx" | |
import "math" | |
const( | |
ACCURACY_DELTA = 0.0000000000000001 | |
) |
OlderNewer