Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
the grass is greener over here, you're the fog that makes it so clear

exhesham.com exhesham

💭
the grass is greener over here, you're the fog that makes it so clear
View GitHub Profile
@exhesham
exhesham / AndroidManifest.xml
Last active Jan 18, 2021
Google sign in process
View AndroidManifest.xml
<application>
....
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
View lock.java
private final Lock lock = new ReentrantLock(isFair);
// usage:
try{
lock.lock();
// Do some stuff
} finally{
lock.unlock();
}
View completable.java
public class RunnableJob implements Runnable{
@Override
public void run() {
}
}
public void runJobs(){
CompletableFuture<Void> f = CompletableFuture.runAsync(new RunnableJob());
f.thenRun(new RunnableJob());
View filter.java
public class FilterLogin implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain){
// inject cookie
Cookie c = getCookie(httpServletResponse, "WASReqURL");
if(c == null){
// inject the cookie if it is not there
c = new Cookie("WASReqURL", "");
httpServletResponse.addCookie(c);
}
String newUrl = "/my_action_servlet";
View uribuilder.java
Uri builtUri = Uri.parse(BASE_URL).buildUpon()
// add various params
.appendQueryParameter(PARAM_QUERY, githubSearchQuery)
.appendQueryParameter(PARAM_SORT, sortBy)
// build the uri
.build();
// Convert the Uri to a URL:
URL url = null;
try {
View onCreateOptionsMenu.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// COMPLETED (9) Within onCreateOptionsMenu, use getMenuInflater().inflate to inflate the menu
getMenuInflater().inflate(R.menu.main, menu);
// COMPLETED (10) Return true to display your menu
return true;
}
View widthandheight.java
public class MainActivity extends AppCompatActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       setContentView(R.layout.activity_main); 
       // other code to setup the activity 
    } 
    // other code 
View importscrolls.java
/*
* Iterate through the array and append the Strings to the TextView. The reason why we add
* the "\n\n\n" after the String is to give visual separation between each String in the
* TextView. Later, we'll learn about a better way to display lists of data.
*/
for (String toyName : toyNames) {
mToysListTextView.append(toyName + "\n\n\n");
}
View ScrollView.xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_weather_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="20sp" />
View liveness_and_Readiness
- kind: ReplicationController
apiVersion: v1
metadata:
name: bad-frontend
labels:
name: bad-frontend
spec:
replicas: 1
selector:
name: bad-frontend