Skip to content

Instantly share code, notes, and snippets.

Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

Block or report user

Report or block guilhermecarvalhocarneiro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:6195234
package base;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
View gist:6195255
protected String doInBackground(City... params) {
// TODO Auto-generated method stub
String nameCity, idCity;
nameCity = "Palmas";
idCity = null;
try {
JSONParser jsonParser = new JSONParser();
String url = "";
JSONObject json = jsonParser.getJSONFromUrl(url);
guilhermecarvalhocarneiro / gist:9097083
Created Feb 19, 2014
Redirecionar conforme limite do usuário
View gist:9097083
def get_form(self, request, obj=None, **kwargs):
form = super(EstabelecimentoAdmin, self).get_form(request, obj, **kwargs)
import pdb
if not request.user.is_superuser:
if Usuario(user=request.user).get_limit() >= self.model.objects.filter(user=request.user).count() and obj == None:
return render_to_response('limit_places.html', {'app_label': 'Limite atingido'})
form.base_fields['cidade'].queryset = Usuario(user=request.user).get_city()
except Exception, e:
View gist:9159757
public class Estado
public int id { get; set; }
public string nome { get; set; }
public string uf { get; set; }
public class City
guilhermecarvalhocarneiro / gist:9189531
Created Feb 24, 2014
Evento Async para pegar as coordenadas atual do usuário
View gist:9189531
private async void StartGeoLocation()
City city = new City();
if (city.GetCurrencyCity() == null)
//TODO Preciso verificar o load da localizacao
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 50;
guilhermecarvalhocarneiro / gist:9207435
Created Feb 25, 2014
Chamando método Async no OnNavegatedTo
View gist:9207435
protected override async void OnNavigatedTo(NavigationEventArgs e)
await StartGeoLocation();
private async Task StartGeoLocation()
View gist:9401632
private void Address_Tap(object sender, System.Windows.Input.GestureEventArgs e)
MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask();
GeoCoordinate CoordenadaFinal = new GeoCoordinate(LatItem, LngItem);
LabeledMapLocation EndPoint = new LabeledMapLocation(PanoramaDetailItem.Title.ToString(), CoordenadaFinal);
mapsDirectionsTask.End = EndPoint;
View gist:9477764
JSONObject jsonobj; // declared locally so that it destroys after serving its purpose
jsonobj = new JSONObject();
JSONObject header = new JSONObject();
jsonobj.put("nome", "Guilherme");
jsonobj.put("pais", "Brasil");
jsonobj.put("chave", regIdGCMService.toString());
jsonobj.put("Authorization", "Token 0d0c898a1c26235f25f256ed853c9a09f3dce8bd");
DefaultHttpClient httpclient = new DefaultHttpClient();
View gist:9493057
def send_message(self):
json_data ={"collapse_key":"msg","data":{"data":"xyz",},"registration_ids":['APA91bH2DtFn9494z-*****bMP1BPUsVI8ltb395MNp-39k8sp0',],}
url =''
myKey ="AIzaSyC********************A7S"
data = json.dumps(json_data)
headers ={'Content-Type':'application/json','Authorization':'key=%s'% myKey}
req = urllib2.Request(url, data, headers)
f = urllib2.urlopen(req)
response = json.loads(
guilhermecarvalhocarneiro / gist:9506197
Created Mar 12, 2014
HttpPost Android para API DjangoRestFramework
View gist:9506197
JSONObject jsonobject = new JSONObject();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://*******/apirestfull/******/");
httppost.setHeader("Authentication", "Token 0d0c898a*****e8bd");
jsonobject.put("nome", "Guilherme");
jsonobject.put("pais", "Brasil");
jsonobject.put("chave", Key);
You can’t perform that action at this time.