Skip to content

Instantly share code, notes, and snippets.

View sergiosvieira's full-sized avatar

Sérgio Vieira sergiosvieira

  • Fortaleza
View GitHub Profile
@sergiosvieira
sergiosvieira / gist:6353003
Created August 27, 2013 12:42
Criar UIView do zero
Open the universityPicker.XIB file
Click on file's owner icon on the left bar
Click on the third tab in the right-hand sidebar
Under "Custom Class" at the top, make sure Class is the name of the ViewController that should correspond to this view. If not, enter it
In the right-hand sidebar, click on the last tab
You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar
Save the xib and re-run
@sergiosvieira
sergiosvieira / gist:6439169
Created September 4, 2013 16:06
fixed section view
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y <= sectionHeaderHeight
&& scrollView.contentOffset.y>=0)
{
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
}
else if (scrollView.contentOffset.y >= sectionHeaderHeight)
{
@sergiosvieira
sergiosvieira / gist:6595304
Created September 17, 2013 14:44
Ignore swipe up and down on pan gesture regocnizer
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer
{
UIView *cell = [gestureRecognizer view];
CGPoint translation = [gestureRecognizer translationInView:[cell superview]];
// Check for horizontal gesture
if (fabsf(translation.x) > fabsf(translation.y))
{
return YES;
}
@sergiosvieira
sergiosvieira / gist:6698852
Created September 25, 2013 12:18
crop a image
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(0, 114, 156, 42));
UIImage * cropedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
@sergiosvieira
sergiosvieira / gist:8880826
Created February 8, 2014 09:52
print wordpress posts
<?php
$args = array(
'posts_per_page' => 3,
'order' => 'DESC'
);
$the_query = new WP_Query($args);
// The Loop
if ( $the_query->have_posts() ) {
@sergiosvieira
sergiosvieira / gist:8890072
Created February 8, 2014 20:46
Novo tipo de post com campos personalizados
add_action( 'init', 'create_post_type' );
function create_post_type() {
$labels = array(
'name' => _x( 'Agendas', 'post type general name' ),
'singular_name' => _x( 'Agenda', 'post type singular name' ),
'add_new' => _x( 'Incluir Agenda', 'book' ),
'add_new_item' => __( 'Incluir Nova Agenda' ),
'edit_item' => __( 'Alterar Agenda' ),
'new_item' => __( 'Nova Agenda' ),
@sergiosvieira
sergiosvieira / gist:9228423
Created February 26, 2014 12:09
Adicionando uma View de um controller dentro de uma view de outro controller
[self addChildViewController:self.contacts];
[self.view addSubview:self.contacts.view];]
desta forma vc pode user self.parentViewController
float[] worldWide = {-180., 90., 360.0, 180.0};
//float[] worldWide = {-45., 22., 90.0, 45.0};
float[] screen = {0., 0., 1024., 512.};
float[] viewPort = {0., 0., 1566., 1045.};
float scale = 1.;
void setup()
{
size((int)viewPort[2], (int)viewPort[3]);
}
@sergiosvieira
sergiosvieira / template.cpp
Last active August 29, 2015 14:05
c++ template problem
#include <iostream>
#include <iomanip>
#include <locale>
#include <sstream>
#include <string> // this should be already included in <sstream>
template<class T>
T* foo(std::string a_str)
@sergiosvieira
sergiosvieira / fluxo-trabalho-git.md
Last active January 31, 2024 01:13
Fluxo de Trabalho Utilizando Git para Pequenas Equipes

Fluxo de Trabalho do Git para Pequenas Equipes

  1. Primeiro, crie um branch de desenvolvimento no seu repositório local:
$ git checkout --track origin/development
  1. Trabalhe em sua tarefa normalmente. Lembre-se de fazer commits frequentes para manter o rastro do seu progresso.