Skip to content

Instantly share code, notes, and snippets.

@nomoa
nomoa / Mock
Created February 2, 2017 18:14
<?php
class MyTest extends MediaWikiTestCase {
public function test() {
$test = $this->getMockBuilder( FooTest::class )
->getMock()
->expects( $this->atLeastOnce() )
->method( 'test' )
->willReturn( 'bar' );
$test->test( "foo" );
}
@nomoa
nomoa / birth_of_a_giant_exception
Created July 6, 2016 17:40
Birth of a giant exception
[2016-07-06 12:54:12,675][WARN ][org.elasticsearch ] Exception cause unwrapping ran for 10 levels...
RemoteTransportException[[elastic1034][10.64.0.235:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1040][10.64.32.108:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1034][10.64.0.235:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1040][10.64.32.108:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1034][10.64.0.235:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1040][10.64.32.108:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1034][10.64.0.235:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1040][10.64.32.108:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1034][10.64.0.235:9300][indices:data/write/bulk[s]]]; nested: RemoteTransportException[[elastic1040][10.64.32.108:9300]
[2016-02-04 10:57:20,814][INFO ][cluster.routing.allocation.decider] [elastic2002] updating [cluster.routing.allocation.enable] from [ALL] to [PRIMARIES]
[2016-02-04 10:57:21,844][INFO ][http ] [elastic2002] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/10.192.0.131:9200]}
[2016-02-04 10:57:21,845][INFO ][node ] [elastic2002] started
[2016-02-04 10:57:59,061][INFO ][cluster.routing.allocation.decider] [elastic2002] updating [cluster.routing.allocation.enable] from [PRIMARIES] to [ALL]
[2016-02-04 11:01:27,960][INFO ][monitor.jvm ] [elastic2002] [gc][young][251][42] duration [703ms], collections [1]/[1.5s], total [703ms]/[3.4s], memory [2.3gb]->[1.7gb]/[29.8gb], all_pools {[young] [667mb]->[10.9mb]/[1.4gb]}{[survivor] [161.8mb]->[137.1mb]/[191.3mb]}{[old] [1.5gb]->[1.6gb]/[28.1gb]}
[2016-02-04 11:01:33,409][WARN ][monitor.jvm ] [elastic2002] [gc][young][255][43] duration [1.4s], collections [1]/[2.4s], total [1.4s]/[4.9s],
PAGE=$1
echo Defaults
curl -s 'https://en.m.wikipedia.org/w/api.php?action=query&format=json&prop=pageterms%7Cpageimages%7Cpageprops&ppprop=mainpage%7Cdisambiguation&wbptterms=description&generator=search&gsrsearch=morelike%3A'$PAGE'&gsrnamespace=0&gsrwhat=text&gsrinfo=&gsrprop=redirecttitle&gsrlimit=5&piprop=thumbnail&pithumbsize=640&pilimit=5&continue=' | jq . | grep "title"
echo =======
echo Opening text (no boost links)
curl -s 'https://en.m.wikipedia.org/w/api.php?action=query&format=json&prop=pageterms%7Cpageimages%7Cpageprops&ppprop=mainpage%7Cdisambiguation&wbptterms=description&generator=search&gsrsearch=morelike%3A'$PAGE'&gsrnamespace=0&gsrwhat=text&gsrinfo=&gsrprop=redirecttitle&gsrlimit=5&piprop=thumbnail&pithumbsize=640&pilimit=5&continue=&cirrusMltUseFields=yes&cirrusMltFields=opening_text&cirrusBoostLinks=no' | jq . | grep "title"
status initializing_shards relocating_shards unassigned_shards
yellow 9 0 197
status initializing_shards relocating_shards unassigned_shards
yellow 16 0 157
^CTraceback (most recent call last):
File "/usr/local/bin/es-tool", line 351, in <module>
sys.exit(commands[args.command]())
File "/usr/local/bin/es-tool", line 330, in <lambda>
"restart-fast": (lambda: es_restart_fast(lambda: 0)),
The doc:
{
labels_de: [
{lang: "de-ch", label:"Blah"},
{lang: "de", label:"Blah2"},
],
labels_en: [
{lang: "en", label:"Foo"},
{lang: "en-gb", label:"Foo2"}
]
$oldTitle = &$this->oldTitle;
$newTitle = &$this->newTitle;
$dbw->onTransactionIdle( function () use ( &$oldTitle, &$newTitle, &$user, $pageid, $redirid, $reason ) {
Hooks::run( 'TitleMoveComplete', array( &$oldTitle, &$newTitle, &$user, $pageid, $redirid, $reason ) );
} );
elastic2002.codfw.wmnet:
checkout status: None [started: 0 mins ago, last-return: None mins ago]
logstash1003.eqiad.wmnet:
checkout status: 0 [started: 0 mins ago, last-return: 999 mins ago]
elastic2022.codfw.wmnet:
checkout status: None [started: 0 mins ago, last-return: None mins ago]
elastic2019.codfw.wmnet:
checkout status: None [started: 0 mins ago, last-return: None mins ago]
elastic2024.codfw.wmnet:
checkout status: None [started: 0 mins ago, last-return: None mins ago]
@nomoa
nomoa / qprob
Created September 16, 2015 10:00
seguintes equaçoes => https://pt.wikipedia.org/wiki/Equa%C3%A7%C3%A3o ????
Wildcards: 1
time: 4
utf32: 3
utf8: 27
factor: 9.0
Wildcards: 2
time: 3
utf32: 10
utf8: 94
factor: 9.4