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
settings index: {number_of_shards: 1} do | |
mappings dynamic: 'false' do | |
indexes :name, analyzer: 'standard', index_options: 'offsets' | |
indexes :description, analyzer: 'standard', index_options: 'offsets' | |
indexes :total_downloads, type: 'long' | |
end | |
end | |
def search(query) | |
__elasticsearch__.search( |
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
{ | |
from: 0, | |
size: 150, | |
query: { | |
filtered: { | |
query: { | |
bool: { | |
should: [ | |
function_score: { | |
query: { |
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
# in spec/support/omniauth_macros.rb | |
module OmniauthMacros | |
def mock_auth_hash | |
# The mock_auth configuration allows you to set per-provider (or default) | |
# authentication hashes to return during integration testing. | |
OmniAuth.config.mock_auth[:twitter] = { | |
'provider' => 'twitter', | |
'uid' => '123545', | |
'user_info' => { | |
'name' => 'mockuser', |
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 'fileutils' | |
class HttpResponse | |
def initialize(text) | |
@text = text | |
@headers = @text.split("\n\n").first | |
@body = @text.split("\n\n")[1] | |
end | |
def headers |
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 Dogs | |
POOR = (0..5).to_a.sample | |
AVERAGE = (6..10).to_a.sample | |
EXCELLENT = (11..15).to_a.sample | |
def initialize | |
joe = { | |
:name => {:first => "Joe", :last=> "Smith"}, | |
:owner_quality => EXCELLENT | |
} |
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 'sinatra/base' | |
require 'rack-flash' | |
class App < Sinatra::Application | |
enable :sessions | |
use Rack::Flash | |
helpers do | |
def h(text) |
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 | |
/** | |
* Created by JetBrains PhpStorm. | |
* User: mint | |
* Date: 9/4/13 | |
* Time: 1:41 AM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
echo "hello"; |
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 | |
include("simple_html_dom.php"); | |
// Create DOM from URL or file | |
$html = file_get_html('http://www.google.com/'); | |
// Find all images | |
/*foreach($html->find('img') as $element) | |
echo $element->src . '<br>'; | |
// Find all links |
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 | |
error_reporting(E_ERROR | E_PARSE); | |
$dom = new DOMDocument(); | |
$dom->loadHTMLFile('http://www.xbox360achievements.org/games/retail/'); | |
$xml = simplexml_import_dom($dom); | |
$links = $xml->xpath('//table/tr/td/a'); | |
for($i=30;$i<count($links);$i++): | |
?> | |
<a target="_blank" href="http://www.xbox360achievements.org/games/retail/<?php echo $links[$i]['href']; ?>"><?php echo $links[$i]['href']; ?></a><br/> | |
<?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
import java.util.Scanner; | |
public class Driver { | |
private int age, carValue, tickets; | |
Scanner in; | |
public Driver(){ | |
this.in = new Scanner(System.in); |
NewerOlder