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
// Sempre atualizar os dados de uma activity, sempre que ela é acessada, coloque suas rotinas no método onResume | |
@Override | |
public void onResume() { | |
super.onResume(); | |
// Suas rotinas | |
} |
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
public void addItem(int position, Object object) { | |
MessageUser message = (MessageUser) object; | |
messages.add(position, message); | |
notifyItemInserted(position); | |
} |
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
// o terceiro parâmetro é uma string json | |
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, paramsPost, | |
new Response.Listener<JSONObject>() { | |
@Override | |
public void onResponse(JSONObject response) { | |
//onPostExecute(response); | |
} | |
}, |
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
recyclerView = (RecyclerView) findViewById(R.id.rvMessagesList); | |
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MessageThreadActivity.this); | |
linearLayoutManager.setStackFromEnd(true); | |
linearLayoutManager.setReverseLayout(false); | |
recyclerView.setLayoutManager(linearLayoutManager); |
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
// With Jquery | |
$(function() { | |
$("#canvas").click(); // simulate click in canvas element | |
}); | |
// Or pure javascript | |
window.onload = function() { | |
var canvasElm = document.getElementById('canvas'); | |
canvasElm.setAttribute('tabindex','0'); | |
canvasElm.focus(); |
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
Script para testar SDK do Facebook: | |
1 - Baixar SDK e importar para o Eclipse | |
2 - Nos projetos de exemplo, excluir a pasta libs | |
3 - Em propriedades -> Android, incluir o Facebook como uma lib | |
Link de referência: | |
http://stackoverflow.com/questions/20399836/friendpickersample-installation-failed-due-to-invalid-apk-file-friendpickersa |
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 | |
public function testIfSetsVariablesInRequestABudgetAction() | |
{ | |
$this->createMocks(); // create mocks for services | |
$this->dispatch('/en/contact/request-a-budget'); | |
$this->assertResponseStatusCode(200); | |
$viewManager = $this->getApplicationServiceLocator()->get('ViewManager'); | |
$variables = $viewManager->getViewModel()->getChildren()[0]->getVariables(); |
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 | |
// use para classe doctrine | |
use Doctrine\ORM\Query\ResultSetMappingBuilder; | |
// código no método de consulta | |
$sql = " SELECT p.* " . | |
" FROM posts p ". | |
" INNER JOIN post_categories_has_posts pcp ON pcp.posts_id = p.id ". |
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 | |
// Onde $this->em recebe o EntityManager | |
$sql = 'SELECT id,titulo FROM posts'; | |
$stmt = $this->em->getConnection()->prepare($sqlSlug); | |
$stmt->bindValue(1, $slugPost); | |
try { | |
$stmt->execute(); |
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 | |
$dataOperacao = '2013-12-23 15:16:17'; | |
$format = 'Y-m-d H:i:s'; | |
$date = DateTime::createFromFormat($format, $dataOperacao); | |
$date->add(new DateInterval('P365D')); | |
echo $date->format('Y-m-d') . "\n"; | |
/** | |
* lê-se os argumentos de DateInterval da seguinte forma: periodo de 365 dias (period of 365 days) |