Skip to content

Instantly share code, notes, and snippets.

View valterh4ck3r's full-sized avatar
🏠
Working from home

Valter Negreiros valterh4ck3r

🏠
Working from home
View GitHub Profile
public class MutableHttpServletRequest extends HttpServletRequestWrapper {
private Map<String,String[]> parameters = new HashMap<String,String[]>();
public MutableHttpServletRequest(HttpServletRequest request) {
super(request);
}
public void setParameter(String name, String value) {
parameters.put(name, new String[] {value});
@valterh4ck3r
valterh4ck3r / promise.md
Created October 29, 2017 16:40 — forked from wkrueger/promise.md
Guia Promise

Guia Promises

Pode-se afirmar que no momento Promises são a forma mais "padrão" no momento de se tratar com assincronismo no JS. Para quem trabalha com javascript, conhecê-las é essencial. Uma dificuldade comum é que esta API tem uma curva de aprendizado um tanto acentuada de início, especialmente se comparado com as alternativas mais antigas: callbacks e o módulo async. No meu caso, levei ao menos uns 3 meses pra "cair a ficha".

-- na verdade promises ainda são um remendo para o problema do assincronismo do JS. Elas ainda possuem certa dificuldade

@valterh4ck3r
valterh4ck3r / buttons_style.xml
Created November 11, 2017 19:02
Buttons Android
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
@valterh4ck3r
valterh4ck3r / text_fields_activity.xml
Created November 11, 2017 19:04
Text Fields Using TextInputLayout and AppCompatEditText.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="br.com.androidpro.textfields.MainActivity">
<android.support.design.widget.TextInputLayout
@valterh4ck3r
valterh4ck3r / keycloak.sh
Created December 12, 2017 14:10 — forked from paoloantinori/keycloak.sh
Keycloak Admin API Rest Example
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin" \
-d 'password=admin' \
-d 'grant_type=password' \
-d 'client_id=admin-cli' | jq -r '.access_token')
curl -X GET 'http://localhost:8080/auth/admin/realms' \
@valterh4ck3r
valterh4ck3r / README-Template.md
Last active December 14, 2017 13:07 — forked from PurpleBooth/README-Template.md
Removed Test Link My Profile

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@valterh4ck3r
valterh4ck3r / timezoneapi.txt
Created January 9, 2018 13:46
Time Zone API
https://timezonedb.com/api
@valterh4ck3r
valterh4ck3r / writeToFile.java
Last active January 10, 2018 00:16
Write in File Android
private void writeToFile(String data) {
try {
File root = new File(Environment.getExternalStorageDirectory(), "Debug");
if (!root.exists()) {
root.mkdirs();
}
File file = new File(root, "debug.txt");
@valterh4ck3r
valterh4ck3r / BadgeNotification.java
Created January 21, 2018 00:07
Badge Notification
public static void setBadge(Context context, int count) {
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
return;
}
Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
intent.putExtra("badge_count", count);
intent.putExtra("badge_count_package_name", context.getPackageName());
intent.putExtra("badge_count_class_name", launcherClassName);
context.sendBroadcast(intent);
@valterh4ck3r
valterh4ck3r / toStringJSON.java
Created February 20, 2018 01:13
toString() in JSON
@Override
public String toString(){
return new Gson().toJson(this);
}