Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / test.java
Created April 4, 2025 16:18
test.java
public class TestAudioFileMain {
private static char sep;
private static String root = "/";
private static char emulateWindows() {
System.setProperty("os.name", "Windows");
System.setProperty("file.separator", "\\");
return '\\';
}
@thinkphp
thinkphp / Aggragation.java
Last active April 4, 2025 17:37
Aggragation
class Adresa {
private String strada;
private String oras;
private String codPostal;
public Adresa(String strada, String oras, String codPostal) {
this.strada = strada;
this.oras = oras;
this.codPostal = codPostal;
}
@thinkphp
thinkphp / Main.java
Created April 4, 2025 14:36
Main.java
package mp3player;
public class Main {
public static void main(String[] args) {
// Testăm clasa AudioFile cu diferite căi de fișiere
AudioFile file1 = new AudioFile("C:\\Music\\Queen - Bohemian Rhapsody.mp3");
System.out.println("Pathname: " + file1.getPathname());
System.out.println("Filename: " + file1.getFilename());
System.out.println("Author: " + file1.getAuthor());
System.out.println("Title: " + file1.getTitle());
@thinkphp
thinkphp / audio
Created April 3, 2025 17:50
audiofile.java
public void parsePathname( String path ) {
this.pathname = ""
this.filename = ""
if(path == null || path.trim().isEmpty()) {
return;
}
@thinkphp
thinkphp / show.map.js
Last active March 16, 2025 17:01
show.map.js
// Function to show map using OpenStreetMap with Leaflet
let map;
let marker;
function showMap(lat, lng, name) {
mapContainer.style.display = 'flex';
// If the map doesn't exist yet, create it
if (!map) {
map = L.map('map').setView([lat, lng], 15);
@thinkphp
thinkphp / view-on-map.js
Last active March 15, 2025 15:06
view-on-map
let buttons = document.querySelectorAll('.view-map');
for (let i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', function() {
const card = this.closest('.place-card');
const lat = card.dataset.lat;
const lng = card.dataset.lng;
const name = card.dataset.name;
if (lat && lng) {
function displayPlaces(places) {
if (places.length === 0) {
resultsContainer.innerHTML = '<div class="loading">No places found. Try a different location or category.</div>';
return;
}
resultsContainer.innerHTML = ""; // Clear previous results
for (let i = 0; i < places.length; ++i) {
const place = places[i];
@thinkphp
thinkphp / display_places.js
Created March 15, 2025 12:37
display_places
for (let i = 0; i < places.length; ++i) {
const place = places[i];
const address = place.location?.formatted_address || place.location?.address || 'Address not available';
const categories = place.categories?.map(cat => cat.name).join(', ') || 'Category not available';
const lat = place.geocodes?.main?.latitude;
const lng = place.geocodes?.main?.longitude;
output += `
<div class="place-card" data-lat="${lat}" data-lng="${lng}" data-name="${place.name}">
<div class="place-image">
// Cerere asincronă simplă
async function cautaProdus() {
// Arată că suntem în proces de încărcare
console.log('Se caută produsul...');
try {
// Trimite cererea - nu blochează alte lucruri
const raspuns = await fetch('https://fakestoreapi.com/products/1');
// Convertește răspunsul în JSON
@thinkphp
thinkphp / async.js
Created March 4, 2025 17:03
functie asyncrona
async function obtineDateUtilizator(idUtilizator) {
try {
// Folosim fetch pentru a face cererea
const raspuns = await fetch(`https://jsonplaceholder.typicode.com/users/${idUtilizator}`);
// Convertim răspunsul în format JSON
const date = await raspuns.json();
// Afișăm datele utilizatorului
console.log('Date utilizator:', date);