Skip to content

Instantly share code, notes, and snippets.

View ibrahim4851's full-sized avatar
🎯
Focusing

ibrahim4851

🎯
Focusing
View GitHub Profile
@ibrahim4851
ibrahim4851 / RecipeTitle.kt
Created October 9, 2023 21:04
RecipeTitle
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RecipeTitle(navController: NavController) {
var recipeTitle by rememberSaveable { mutableStateOf("") }
Surface(
modifier = Modifier.fillMaxSize()
)
@ibrahim4851
ibrahim4851 / fetchNbaColors.py
Created July 4, 2022 18:45
This script allows you to get the NBA teams' colors in xml format. You need to download requests library for python.
import requests
import json
import string
def getTeamColorData(url):
r = requests.get(url)
data = r.json()
for item in data:
erasArray = item['eras'][0]['colors']
print(item['name'])
<?php
$value = $_POST["value"];
$jsondata = '{
"value": "request successfull"
}';
if ($id != null) {
echo($jsondata);
}
fun postString(context: Context?) {
val queue = Volley.newRequestQueue(context)
val sr: StringRequest = object : StringRequest(
Method.POST, "http://favor4u.xyz/calisma/samplepost.php",
Response.Listener { response ->
val res = JSONObject(response)
val value = res.getString("value")
Toast.makeText(context, "Successful", Toast.LENGTH_SHORT).show()
Log.i("value", value)
}, Response.ErrorListener { error ->
fun getRequest() {
var url = "https://raw.githubusercontent.com/ibrahim4851/VolleyRequests/master/nestedjson.json"
val queue: RequestQueue = Volley.newRequestQueue(this)
val request = JsonObjectRequest(
Request.Method.GET,
url,
null,
{ response ->
val glossary = response.getJSONObject("glossary")
val GlossDiv = glossary.getJSONObject("GlossDiv")
@ibrahim4851
ibrahim4851 / GetJsonArray.kt
Last active May 22, 2021 12:16
VolleyGetArray
fun getJsonArray() {
val requestQueue: RequestQueue = Volley.newRequestQueue(this)
val jsonArrayRequest =
JsonArrayRequest("https://raw.githubusercontent.com/ibrahim4851/VolleyRequests/master/jsonarray.json",
{ response ->
for (i in 0 until response.length()) {
try {
val jsonObject = response.getJSONObject(i)
val title = jsonObject.getString("title")
val description = jsonObject.getString("description")
@ibrahim4851
ibrahim4851 / MainActivity.kt
Created May 22, 2021 11:46
MainActivityVolley
private lateinit var getarray: Button
private lateinit var getobject: Button
private lateinit var postobject: Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
getarray = findViewById(R.id.getarray)
getobject = findViewById(R.id.getobject)
@ibrahim4851
ibrahim4851 / activity_main.xml
Created May 22, 2021 11:43
MainActivityXmlVolley
<?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"
android:gravity="center"
tools:context=".MainActivity">
@ibrahim4851
ibrahim4851 / AndroidManifest.xml
Created May 22, 2021 11:26
VolleyRequestsManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibrahim.volleyrequests">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:usesCleartextTraffic="true"
...
</application>
@ibrahim4851
ibrahim4851 / detectImage.kt
Created May 4, 2021 22:48
DetectImageMlkit
fun detectImage() {
val recognizer = TextRecognition.getClient()
bitmap?.let {
val image = InputImage.fromBitmap(it, 0)
recognizer.process(image)
.addOnSuccessListener { visionText ->
Toast.makeText(this, visionText.text, Toast.LENGTH_SHORT).show()
}
.addOnFailureListener { e ->
Toast.makeText(this, "Error: " + e.message, Toast.LENGTH_SHORT).show()