Skip to content

Instantly share code, notes, and snippets.

View emersonbroga's full-sized avatar
:octocat:
Let's code!

Emerson Brôga emersonbroga

:octocat:
Let's code!
View GitHub Profile
@emersonbroga
emersonbroga / gist:2482748
Created April 24, 2012 19:03
Get Image Path from Wordpress Image URL
<?php
defined('UPLOAD_PATH') || define('UPLOAD_PATH', 'path_to_wp-content_uploads');
$url = 'image_URL'; //Image url like http://www.site.com/wp-content/uploads/year/month/image.jpg
$parts = array_slice(explode('/', $url), -3);
$imagePath = UPLOAD_PATH . implode(DIRECTORY_SEPARATOR, $parts);
if(file_exists($imagePath))
{
@emersonbroga
emersonbroga / ViewController.m
Created April 26, 2012 19:12
Emerson Carvalho.com >> iOS App: Criando um ScrollView (snippet 1)
//Passo 1: Criar algumas variaveis uteis.
int screenWidth = self.view.bounds.size.width; //Largura da tela
int screenHeight = self.view.bounds.size.height;//Altura da Tela
int numberOfViews = 3; //Quantidade de views
//Passo 1: Criar o ScrollView
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame: CGRectMake(0, 0, screenWidth, screenHeight)];
//Passo 2: Um loop para criar as views
for (int i=0; i<numberOfViews;i++) {
@emersonbroga
emersonbroga / ViewController.m
Created April 26, 2012 19:15
Emerson Carvalho.com >> iOS App: Criando um ScrollView (snippet 2)
[scrollView setPagingEnabled:YES];
@emersonbroga
emersonbroga / AppDelegate.m
Created April 27, 2012 13:56
Emerson Carvalho.com >> iOS esconder o teclado ao tocar fora do UITextField (snippet 1)
- (BOOL)canBecomeFirstResponder {
return YES;
}
@emersonbroga
emersonbroga / AppDelegate.m
Created April 27, 2012 13:56
Emerson Carvalho.com >> iOS esconder o teclado ao tocar fora do UITextField (snippet 2)
- (void)viewDidAppear:(BOOL)animated {
[self becomeFirstResponder];
}
@emersonbroga
emersonbroga / AppDelegate.m
Created April 27, 2012 13:57
Emerson Carvalho.com >> iOS esconder o teclado ao tocar fora do UITextField (snippet 3)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
//Verifique se o seu textField está com o teclado aberto e se o toque foi fora dele.
if ([myTextField isFirstResponder] && [touch view] != myTextField) {
[myTextField resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
@emersonbroga
emersonbroga / IndexController.php
Created April 27, 2012 14:01
Emerson Carvalho.com >> Zend Framework Controller Action Helpers (snippet 1)
<?php
public function indexAction(){
$this->_helper->layout()->disableLayout();
}
?>
@emersonbroga
emersonbroga / IndexController.php
Created April 27, 2012 14:02
Emerson Carvalho.com >> Zend Framework Controller Action Helpers (snippet 2)
<?php
public function indexAction(){
$this->_helper->layout()->setLayout('novo_layout');
}
?>
@emersonbroga
emersonbroga / IndexController.php
Created April 27, 2012 14:02
Emerson Carvalho.com >> Zend Framework Controller Action Helpers (snippet 3)
<?php
public function indexAction(){
$this->_helper->viewRenderer->setNoRender(true);
}
?>
@emersonbroga
emersonbroga / IndexController.php
Created April 27, 2012 14:03
Emerson Carvalho.com >> Zend Framework Controller Action Helpers (snippet 4)
<?php
function indexAction(){
$this->_helper->viewRenderer('VIEW QUE DESEJA RENDERIZAR', null, true);
}
?>