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
winners[buyer] ||= [] is a shortcut to: | |
winners[buyer] = winners[buyer] || [] is a shortcut to: | |
Set winners[buyer] equal to winners[buyer] or, if winners[buyer] is nil, set it to []. | |
You’re just making sure a variable is set before using it. |
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
class Report | |
def output | |
formatter_class = | |
begin | |
@format.to_s.classify.constantize | |
rescue NameError | |
# ...handle 'invalid formatter type' | |
end | |
formatter = formatter_class.send(:new, self) | |
# etc |
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 | |
use \eZ\Publish\API\Repository\Values\Content\Query; | |
$locationService = $this->getRepository()->getLocationService(); | |
$searchService = $this->getRepository()->getSearchService(); | |
$urlAliasService = $this->getRepository()->getUrlAliasService(); | |
$typeService = $this->getRepository()->getContentTypeService(); | |
$identifiers = array( 'folder', 'page', 'contact' ); | |
$ids = array(); |
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
$attributeFilter = array( array( 'user/sync_time', '=', '' ), | |
// array( 'user/guid', '=', '' ), | |
//array( 'user/user_settings/is_enabled', '=', 1 ), | |
array( 'modified', '>', $last_modified) | |
); | |
$params = array( | |
/* | |
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
{fetch( 'content', 'list', | |
hash( 'parent_node_id', 42, | |
'attribute_filter', array( 'or', | |
array( 152, '=', 'abc' ), | |
array( 153, '=', '42' ) ) ) )} |
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
java -jar ./selenium-server-standalone-2.39.0.jar -Dwebdriver.chrome.driver=./chromedriver-2.8 | |
Selenium Server | |
http://docs.seleniumhq.org/download/ | |
Chrome Driver | |
http://chromedriver.storage.googleapis.com/index.html |
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 'vendor/swiftmailer/swiftmailer/lib/swift_required.php'; | |
$transport = Swift_SmtpTransport::newInstance('smtp.host.com', 25, 'tls') | |
->setUsername('') | |
->setPassword(''); | |
$mailer = Swift_Mailer::newInstance($transport); | |
$message = Swift_Message::newInstance('Informação') |
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
This md5("test\n") is diferent this one md5('test\n') | |
md5("test\n") = 'd8e8fca2dc0f896fd7cb4cb0031ba249' | |
md5('test\n') = 'e55a2a99dcc719bb178a5e6daf3d4f98' | |
Single quoted - strings will display things almost completely "as is." Variables and most escape sequences will not be interpreted. The exception is that to display a literal single quote, you can escape it with a back slash \', and to display a back slash, you can escape it with another backslash \\ (So yes, even single quoted strings are parsed). | |
Double quote - strings will display a host of escaped characters (including some regexes), and variables in the strings will be evaluated. An important point here is that you can use curly braces to isolate the name of the variable you want evaluated. For example let's say you have the variable $type and you what to echo "The $types are" That will look for the variable $types. To get around this use echo "The {$type}s are" You can put the left brace before or after the dollar sign. Take a look at string parsi |
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 | |
// Try to log the user in. | |
if (Auth::attempt($userdata)) | |
{ | |
// Redirect to homepage | |
return Redirect::to('')->with('success', 'You have logged in successfully'); | |
} | |
else | |
{ | |
$user = User::where('username','=',$userdata['username'])->first(); |
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
#! /bin/bash | |
# Run this as sudo! | |
# I move this file to /usr/local/bin/vhost and run command 'vhost' from anywhere, using sudo. | |
# | |
# Show Usage, Output to STDERR | |
# | |
function show_usage { | |
cat <<- _EOF_ |
OlderNewer