This file contains hidden or 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
~/Sites/bits ᐅ ruby montyhall.rb | |
Runs: 1000000 | |
Sticking wins: 33.3413% | |
Switching wins: 66.6587% |
This file contains hidden or 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 | |
class Search_model extends CI_Model | |
{ | |
protected $tables = array( | |
'users' => array( 'name', 'email' ) | |
); | |
public function run($search) | |
{ |
This file contains hidden or 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
{ | |
"Business, Innovation and Skills Select Committee (overseeing the operations of the Department for Business, Innovation and Skills and related bodies)": { | |
"members": [ | |
{ | |
"member": "Adrian Bailey MP (Chair)", | |
"member_chair": true, | |
"party": "Labour Co-op" | |
}, | |
{ | |
"member": "Brian Binley MP", |
This file contains hidden or 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 | |
for ($i = 1; $i < 101; $i++) | |
{ | |
if (($i % 3) == 0) | |
{ | |
$line = "Fizz"; | |
} | |
elseif (($i % 5) == 0) | |
{ |
This file contains hidden or 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": { | |
"phpunit/phpunit": "3.7.*" | |
} | |
} |
This file contains hidden or 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 | |
namespace App\Tests\Unit; | |
use App\Models\User as User; | |
class UserControllerTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testMostPopular() | |
{ |
This file contains hidden or 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
def search id | |
Model.find id | |
rescue => e | |
log "Error in search: #{e.message}" | |
end |
This file contains hidden or 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 | |
$mongo.prototype.extend( | |
{ | |
public function get($collection) | |
{ | |
this.prototype._find({ collectionName: $collection }); | |
} | |
}); |
This file contains hidden or 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
$ ruby popularity_test.rb | |
Loaded suite popularity_test | |
Started | |
. | |
Finished in 0.000979 seconds. | |
1 tests, 4 assertions, 0 failures, 0 errors, 0 skips |
This file contains hidden or 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
# Let's say we have an email message body with some headers and then the email | |
# content. Just like HTTP, headers\n\nbody | |
string = "Header: here\n\nHere is an email\n\nwith some line breaks\n\nand stuff" | |
# What you'd expect (what PHP's explode() does) | |
string.split("\n\n", 2) == [ "Header: here", "Here is an email\n\nwith some line breaks\n\nand stuff" ] # false | |
# What you actually get | |
string.split("\n\n", 2) == [ "Header: here", "Here is an email" ] # true |