{ "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": ":newspaper: STAY IN THE KNOW :newspaper:" } }, { "type": "context", "elements": [ { "text": "*February 2024* | Monthly Spotlight", "type": "mrkdwn" } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "FOR YOUR INFORMATION", "style": { "bold": true } }, { "type": "text", "text": "\n\nStay in the loop about what’s happening at the office such as upcoming visitors, onsite meetings, lunches, and more. Don’t miss out—click to subscribe below." } ] } ] }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": ":google-workspace-calendar: *NYC Happenings* calendar" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "Click to subscribe", "emoji": true }, "value": "click_me_123", "url": "https://calendar.google.com/calendar/u/0?cid=Y19iMzQyMGZiNWFjMDU5ZTFlMDM2ZGJkMjEwOTBhODc1YmI3YjJlYzQ3NWY3MTRmZWNjZGNlZjMwNDkzNGQ0ODA2QGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20", "action_id": "button-action" } }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "office-building" }, { "type": "text", "text": " | " }, { "type": "text", "text": "Building Announcements ", "style": { "bold": true } }, { "type": "text", "text": "| " }, { "type": "emoji", "name": "office-building" }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/13", "style": { "code": true } }, { "type": "text", "text": " Would you like to be our Valentine? Join\nus at the lobby for some sweet treats!\n" }, { "type": "text", "text": "2/19", "style": { "code": true } }, { "type": "text", "text": " President's Day, Property Management Office will be closed" } ] } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "announcement-blue" }, { "type": "text", "text": " " }, { "type": "text", "text": "ANNOUNCEMENT", "style": { "bold": true } }, { "type": "text", "text": " " }, { "type": "emoji", "name": "announcement-blue" }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/15", "style": { "code": true } }, { "type": "text", "text": " Our host for the US Stand Up is Taylor Maiman!\n" } ] }, { "type": "rich_text_preformatted", "border": 0, "elements": [ { "type": "text", "text": "If you're keen on leading one, don't hesitate to reach out to wxhelp@xero.com!" } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "2/21 & 2/22", "style": { "code": true } }, { "type": "text", "text": " Leadership Onsite" } ] } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "date", "unicode": "1f4c5" }, { "type": "text", "text": " | " }, { "type": "text", "text": "THURSDAY LUNCH SCHEDULE", "style": { "bold": true } }, { "type": "text", "text": " | " }, { "type": "emoji", "name": "date", "unicode": "1f4c5" }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/8", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "emoji", "name": "chinese-lantern" }, { "type": "text", "text": " " }, { "type": "text", "text": "Ollie's Sichuan", "style": { "bold": true, "italic": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/15", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "text", "text": "Lenwich", "style": { "bold": true, "italic": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/22", "style": { "code": true } }, { "type": "text", "text": " Chopt Creative Salad Co", "style": { "bold": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/29", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "text", "text": "Sophie's Cuban Cuisine", "style": { "bold": true } } ] } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_quote", "elements": [ { "type": "text", "text": "WX offers comprehensive event planning services, including:" } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "\n" } ] }, { "type": "rich_text_list", "style": "bullet", "indent": 0, "border": 0, "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Assistance with logistics and coordination " } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Access to a network of vendors for catering, supply ordering, etc." } ] } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "\nNote: Even if you don’t need our assistance but are using the office space, kindly inform WX." } ] } ] }, { "type": "context", "elements": [ { "type": "mrkdwn", "text": ":pushpin: Have something important to add to our calendar? Get in touch with us at wxhelp@xero.com and let us know. We're here to help!" } ] } ] }
{ "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": ":newspaper: STAY IN THE KNOW :newspaper:" } }, { "type": "context", "elements": [ { "text": "*February 2024* | Monthly Spotlight", "type": "mrkdwn" } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "FOR YOUR INFORMATION", "style": { "bold": true } }, { "type": "text", "text": "\n\nStay in the loop about what’s happening at the office such as upcoming visitors, onsite meetings, lunches, and more. Don’t miss out—click to subscribe below." } ] } ] }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": ":google-workspace-calendar: *SFO Happenings* calendar" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "Click to subscribe", "emoji": true }, "value": "click_me_123", "url": "https://calendar.google.com/calendar/u/0?cid=Y184MjJkZWFkYWYyMjhiMWNhZmM0NjQ4NTA4MmMzY2E4ZjNlNjgyZDg0NGIzODFmYTYwZjRlNGU1ODUxOTdmNjhhQGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20", "action_id": "button-action" } }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "announcement-blue" }, { "type": "text", "text": " " }, { "type": "text", "text": "ANNOUNCEMENT", "style": { "bold": true } }, { "type": "text", "text": " " }, { "type": "emoji", "name": "announcement-blue" }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/15", "style": { "code": true } }, { "type": "text", "text": " Our host for the US Stand Up is Taylor Maiman!\n" } ] }, { "type": "rich_text_preformatted", "border": 0, "elements": [ { "type": "text", "text": "If you're keen on leading one, don't hesitate to reach out to wxhelp@xero.com!" } ] } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ { "type": "emoji", "name": "date", "unicode": "1f4c5" }, { "type": "text", "text": " | " }, { "type": "text", "text": "THURSDAY LUNCH SCHEDULE", "style": { "bold": true } }, { "type": "text", "text": " | " }, { "type": "emoji", "name": "date", "unicode": "1f4c5" }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/8", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "text", "text": " ", "style": { "bold": true, "italic": true } }, { "type": "emoji", "name": "chinese-lantern", "style": { "bold": true, "italic": true } }, { "type": "text", "text": " Little Szechuan", "style": { "bold": true, "italic": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/15", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "text", "text": "The Grove - Yerba Buena", "style": { "bold": true, "italic": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/22", "style": { "code": true } }, { "type": "text", "text": " RT Rotisserie", "style": { "bold": true } }, { "type": "text", "text": "\n\n" }, { "type": "text", "text": "2/29", "style": { "code": true } }, { "type": "text", "text": " " }, { "type": "text", "text": "sweetgreen", "style": { "bold": true } } ] } ] }, { "type": "divider" }, { "type": "rich_text", "elements": [ { "type": "rich_text_quote", "elements": [ { "type": "text", "text": "WX offers comprehensive event planning services, including:" } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "\n" } ] }, { "type": "rich_text_list", "style": "bullet", "indent": 0, "border": 0, "elements": [ { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Assistance with logistics and coordination " } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "Access to a network of vendors for catering, supply ordering, etc." } ] } ] }, { "type": "rich_text_section", "elements": [ { "type": "text", "text": "\nNote: Even if you don’t need our assistance but are using the office space, kindly inform WX." } ] } ] }, { "type": "divider" }, { "type": "context", "elements": [ { "type": "mrkdwn", "text": ":pushpin: Have something important to add to our calendar? Don’t hesitate to reach out if you have any questions or concerns. Get in touch with us at wxhelp@xero.com and let us know. We're here to help!" } ] } ] }
Unlock the potential of Telegram with our custom Telegram Mini Apps development services. Our skilled developers create versatile, lightweight mini apps that seamlessly integrate with Telegram, enhancing user engagement and offering a unique digital experience. From e-commerce solutions and payment gateways to customer support bots and interactive content, we build Telegram Mini Apps that elevate your business presence on the platform. We focus on delivering secure, scalable, and feature-rich apps that provide a smooth user experience and leverage the vast reach of Telegram’s ecosystem. Transform your business communication and customer interaction with innovative Telegram Mini Apps tailored to your specific needs.
If you’re searching for the best SEO services for your business, NounQ Technologies is a top SEO company in India. By using successive SEO tactics our digital marketing experts improve the website's organic visibility and maintain high rank in Search Engine. Our experts monitor your campaign manually by identifying areas for improvement and the needs of your targeted clients and work according to it. Our SEO services are committed towards providing effective and ethical Search Engine Optimization for both small and large scale businesses. Our SEO company works for you to create and promote valuable content according to the needs of clients.
void confirmDialog( String req, TicketModel ticket, List<AuthModel> assignToPersonList) { try { if (req == "Approve") { timeDurationController.clear(); showDialog( barrierDismissible: false, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return AlertDialog( title: Center( child: Text( "Verify", style: Theme.of(context).textTheme.bodyLarge, ), ), content: SizedBox( height: 200, child: Column( children: [ DropdownButtonFormField<String>( validator: (value) { if (value == null) { return 'Please select a Person to Assign'; } return null; }, decoration: InputDecoration( labelText: "Person to Assign", border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), style: Theme.of(context).textTheme.bodyLarge, iconSize: 30, hint: const Text("Select Person to Assign"), items: assignToPersonList.map((authModel) { return DropdownMenuItem( value: authModel.uid, child: Text(authModel.fullName), ); }).toList(), onChanged: (String? value) { setState(() { selectedPerson = value; }); }, ), const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ElevatedButton( onPressed: () { setState(() { isHourly = true; timeDurationController.clear(); }); }, style: ElevatedButton.styleFrom( backgroundColor: isHourly ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 17, 17, 17), ), child: const Text("Hourly"), ), ElevatedButton( onPressed: () { setState(() { isHourly = false; }); }, style: ElevatedButton.styleFrom( backgroundColor: !isHourly ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 17, 17, 17), ), child: const Text("Day"), ), ], ), const SizedBox(height: 20), TextField( controller: timeDurationController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly, ], decoration: InputDecoration( labelText: isHourly ? "Time Duration (Hours)" : "Time Duration (Days)", border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), // Restrict input based on mode onChanged: (value) { if (value.isNotEmpty) { int enteredValue = int.parse(value); if (isHourly) { // If hourly, restrict between 1 and 7 if (enteredValue < 1 || enteredValue > 7) { timeDurationController.text = "1"; } } else { // If day-wise, restrict between 1 and 60 if (enteredValue < 1 || enteredValue > 60) { timeDurationController.text = "1"; } } // Set the cursor position at the end of the text timeDurationController.selection = TextSelection.fromPosition( TextPosition( offset: timeDurationController.text.length), ); } }, ), ], ), ), actions: <Widget>[ TextButton( child: const Text('Cancel'), onPressed: () { Navigator.pop(context); }, ), ElevatedButton( child: const Text('Approve'), onPressed: () async { if (selectedPerson != null && timeDurationController.text.isNotEmpty) { int timeDuration = int.parse(timeDurationController.text); if (!isHourly) { timeDuration *= 7; } ticket.assignTo = selectedPerson!; ticket.timeDuration = timeDuration; ticket.status = TicketStatus.inProgress; ref .read(ticketControllerProvider) .updateTicket(ref, ticket); ref.invalidate(ticketListStreamProvider); ref.invalidate(ticketsByCreatedByStreamProvider); Navigator.pop(context); } else { log("Error: Please fill all fields."); } }, ), ], ); }, ); }, ); } else if (req == "Reject") { TextEditingController rejectReason = TextEditingController(); final GlobalKey<FormState> _reject = GlobalKey<FormState>(); showDialog( barrierDismissible: false, context: context, builder: (context) { return AlertDialog( title: Center( child: Text( "Verify", style: Theme.of(context).textTheme.bodyLarge, ), ), content: SizedBox( height: 120, child: Form( key: _reject, child: TextFormField( validator: (text) { if (text == null || text.isEmpty) { return 'Please enter a reason for rejecting the request'; } return null; }, controller: rejectReason, keyboardType: TextInputType.text, textCapitalization: TextCapitalization.words, decoration: InputDecoration( labelText: "Reason for Rejection", hintText: "Enter reason to reject the request", border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), ), ), ), actions: <Widget>[ TextButton( child: const Text('Cancel'), onPressed: () { Navigator.pop(context); }, ), ElevatedButton( child: const Text('Reject'), onPressed: () async { if (_reject.currentState!.validate()) { ticket.status = TicketStatus.rejected; ticket.rejectionRemark = rejectReason.text; ref .read(ticketControllerProvider) .updateTicket(ref, ticket); ref.invalidate(ticketListStreamProvider); ref.invalidate(ticketsByCreatedByStreamProvider); Navigator.pop(context); } }, ), ], ); }, ); } } catch (e) { log("Error occurred: $e"); } } void confirmDialog( String req, TicketModel ticket, List<AuthModel> assignToPersonList) { try { if (req == "Approve") { timeDurationController.clear(); showDialog( barrierDismissible: false, context: context, builder: (context) { return StatefulBuilder( builder: (context, setState) { return AlertDialog( title: Center( child: Text( "Verify", style: Theme.of(context).textTheme.bodyLarge, ), ), content: SizedBox( height: 200, child: Column( children: [ DropdownButtonFormField<String>( validator: (value) { if (value == null) { return 'Please select a Person to Assign'; } return null; }, decoration: InputDecoration( labelText: "Person to Assign", border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), style: Theme.of(context).textTheme.bodyLarge, iconSize: 30, hint: const Text("Select Person to Assign"), items: assignToPersonList.map((authModel) { return DropdownMenuItem( value: authModel.uid, child: Text(authModel.fullName), ); }).toList(), onChanged: (String? value) { setState(() { selectedPerson = value; }); }, ), const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ElevatedButton( onPressed: () { setState(() { isHourly = true; timeDurationController.clear(); }); }, style: ElevatedButton.styleFrom( backgroundColor: isHourly ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 17, 17, 17), ), child: const Text("Hourly"), ), ElevatedButton( onPressed: () { setState(() { isHourly = false; }); }, style: ElevatedButton.styleFrom( backgroundColor: !isHourly ? Color.fromARGB(255, 0, 0, 0) : Color.fromARGB(255, 17, 17, 17), ), child: const Text("Day"), ), ], ), const SizedBox(height: 20), TextField( controller: timeDurationController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly, ], decoration: InputDecoration( labelText: isHourly ? "Time Duration (Hours)" : "Time Duration (Days)", border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), onChanged: (value) { if (value.isNotEmpty) { int enteredValue = int.parse(value); if (isHourly) { // If hourly, restrict between 1 and 7 if (enteredValue < 1 || enteredValue > 7) { timeDurationController.text = "1"; } } else { // If day-wise, restrict between 1 and 60 if (enteredValue < 1 || enteredValue > 60) { timeDurationController.text = "1"; } } timeDurationController.selection = TextSelection.fromPosition( TextPosition( offset: timeDurationController.text.length), ); } }, ), ], ), ), actions: <Widget>[ TextButton( child: const Text('Cancel'), onPressed: () { Navigator.pop(context); }, ), ElevatedButton( child: const Text('Approve'), onPressed: () async { if (selectedPerson != null && timeDurationController.text.isNotEmpty) { int timeDuration = int.parse(timeDurationController.text); ticket.assignTo = selectedPerson!; // Store the current time in assigningTime DateTime assigningTime = DateTime.now(); ticket.assigningTime = assigningTime; if (!isHourly) { // Convert days to hours for storing as timeDuration timeDuration *= 24; } // Add timeDuration to assigningTime to calculate estimatedTime ticket.estimatedTime = assigningTime.add(Duration(hours: timeDuration)); ticket.timeDuration = timeDuration; ticket.status = TicketStatus.inProgress; ref .read(ticketControllerProvider) .updateTicket(ref, ticket); ref.invalidate(ticketListStreamProvider); ref.invalidate(ticketsByCreatedByStreamProvider); Navigator.pop(context); } else { log("Error: Please fill all fields."); } }, ), ], ); }, ); }, ); } else if (req == "Reject") { // Code for Reject case } } catch (e) { log("Error occurred: $e"); } }
Use Node.js built-in tools with --inspect and Chrome DevTools for profiling. Use clinic.js for comprehensive performance analysis. Use memwatch-next for detecting memory leaks. Use heapdump for taking heap snapshots. Use autocannon for performance benchmarking.
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; import 'dart:ui'; import 'package:enum_to_string/enum_to_string.dart'; import 'package:rrispat_app/src/features/ticket/ticket_enums.dart'; class TicketModel { String id; String createdBy; String userDepartment; String assignTo; String againstDepartment; String hod; String subDepartment; String teamLead; int timeDuration; String description; DateTime? createdAt; TicketStatus status; int userRating; UserReviewStatus userReviewStatus; String rejectionRemark; String reviewRemark; List<String> solutionRemarks = []; DateTime? assigningTime; DateTime? estimatedTime; TicketModel({ this.id = '', this.createdBy = '', this.userDepartment = '', this.assignTo = '', this.againstDepartment = '', this.hod = '', this.subDepartment = '', this.teamLead = '', this.timeDuration = 0, this.description = '', this.userRating = 0, this.rejectionRemark = '', this.reviewRemark = '', this.solutionRemarks = const [], this.userReviewStatus = UserReviewStatus.reviewNotReceived, this.createdAt, this.assigningTime, this.estimatedTime, this.status = TicketStatus.created, // required this.status, }); TicketModel copyWith({ String? id, String? createdBy, String? userDepartment, String? assignTo, String? againstDepartment, String? hod, String? subDepartment, String? teamLead, int? timeDuration, String? description, int? userRating, UserReviewStatus? userReviewStatus, String? rejectionRemark, String? reviewRemark, List<String>? solutionRemarks, DateTime? createdAt, TicketStatus? status, }) { return TicketModel( id: id ?? this.id, createdBy: createdBy ?? this.createdBy, userDepartment: userDepartment ?? this.userDepartment, assignTo: assignTo ?? this.assignTo, againstDepartment: againstDepartment ?? this.againstDepartment, hod: hod ?? this.hod, subDepartment: subDepartment ?? this.subDepartment, teamLead: teamLead ?? this.teamLead, timeDuration: timeDuration ?? this.timeDuration, description: description ?? this.description, userRating: userRating ?? this.userRating, userReviewStatus: userReviewStatus ?? this.userReviewStatus, rejectionRemark: rejectionRemark ?? this.rejectionRemark, reviewRemark: reviewRemark ?? this.reviewRemark, solutionRemarks: solutionRemarks ?? this.solutionRemarks, createdAt: createdAt ?? this.createdAt, status: status ?? this.status, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'id': id, 'createdBy': createdBy, 'userDepartment': userDepartment, 'assignTo': assignTo, 'againstDepartment': againstDepartment, 'hod': hod, 'subDepartment': subDepartment, 'teamLead': teamLead, 'timeDuration': timeDuration, 'description': description, 'userRating': userRating, 'userReviewStatus': userReviewStatus.name, 'rejectionRemark': rejectionRemark, 'reviewRemark': reviewRemark, 'solutionRemarks': solutionRemarks, 'createdAt': createdAt?.millisecondsSinceEpoch, 'status': status.name, }; } factory TicketModel.fromMap(Map<String, dynamic> map) { return TicketModel( id: map['_id'] as String, createdBy: (map['createdBy'] ?? '') as String, userDepartment: (map['userDepartment'] ?? '') as String, assignTo: (map['assignTo'] ?? '') as String, againstDepartment: (map['againstDepartment'] ?? '') as String, hod: (map['hod'] ?? '') as String, subDepartment: (map['subDepartment'] ?? '') as String, teamLead: (map['teamLead'] ?? '') as String, timeDuration: (map['timeDuration'] ?? 0) as int, description: (map['description'] ?? '') as String, userRating: (map['userRating'] ?? 0) as int, rejectionRemark: (map['rejectionRemark'] ?? '') as String, reviewRemark: (map['reviewRemark'] ?? '') as String, solutionRemarks: List<String>.from(map['solutionRemarks'] ?? []), createdAt: DateTime.parse((map['createdAt'])), status: EnumToString.fromString(TicketStatus.values, map['status'].toString()) as TicketStatus, userReviewStatus: EnumToString.fromString( UserReviewStatus.values, map['userReviewStatus'].toString()) as UserReviewStatus, ); } String toJson() => json.encode(toMap()); factory TicketModel.fromJson(String source) => TicketModel.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() { return 'TicketModel(id: $id, createdBy: $createdBy, userDepartment: $userDepartment, assignTo: $assignTo, againstDepartment: $againstDepartment, hod: $hod, subDepartment: $subDepartment, teamLead: $teamLead, timeDuration: $timeDuration, description: $description,userRating: $userRating,userReviewStatus: $userReviewStatus, rejectionRemark: $rejectionRemark,reviewRemark: $reviewRemark,solutionRemarks: $solutionRemarks, createdAt: $createdAt, status: $status)'; } @override bool operator ==(covariant TicketModel other) { if (identical(this, other)) return true; return other.id == id && other.createdBy == createdBy && other.userDepartment == userDepartment && other.assignTo == assignTo && other.againstDepartment == againstDepartment && other.hod == hod && other.subDepartment == subDepartment && other.teamLead == teamLead && other.timeDuration == timeDuration && other.description == description && other.userRating == userRating && other.userReviewStatus == userReviewStatus && other.rejectionRemark == rejectionRemark && other.reviewRemark == reviewRemark && other.solutionRemarks == solutionRemarks && other.createdAt == createdAt && other.status == status; } @override int get hashCode { return hashList([ id, createdBy, userDepartment, assignTo, againstDepartment, hod, subDepartment, teamLead, timeDuration, description, userRating, userReviewStatus, rejectionRemark, reviewRemark, solutionRemarks, createdAt, status, ]); } }
def lines_that_equal(line_to_match, fp): return [line for line in fp if line == line_to_match] def lines_that_contain(string, fp): return [line for line in fp if string in line] def lines_that_start_with(string, fp): return [line for line in fp if line.startswith(string)] def lines_that_end_with(string, fp): return [line for line in fp if line.endswith(string)]
#include <iostream> using namespace std; int main() { int array_length, element_to_delete, index = -1; cout << "--------------Program for DELETING AN ELEMENT of an Array--------------\n" << endl; cout << "Enter the size of your Array: "; cin >> array_length; int nums[array_length]; cout << "\n"; cout << "Input " << array_length << " elements: " << endl; for(int i = 0; i < array_length; i++) { cin >> nums[i]; } cout << "\n"; cout << "Enter the element you wish to delete: "; cin >> element_to_delete; for(int i = 0; i < array_length; i++) { if(nums[i] == element_to_delete) { index = i; break; } } if(index == -1) { cout << "Element not found. No deletion performed." << endl; return 0; } cout << "\n"; for(int i = index; i < array_length; i++) { nums[i] = nums[i + 1]; } array_length--; cout << "\n"; cout << "Updated Array: " << endl; for(int i = 0; i < array_length; i++) { cout << nums[i] << " "; } }
#include <iostream> using namespace std; int main() { int array_length; cout << "--------------Program to check for PEAK ELEMENTS in an Array.--------------\n" << endl; cout << "Enter the array length: "; cin >> array_length; int nums[array_length]; cout << "\n"; cout << "Input array elements: " << endl; for(int i = 0; i < array_length; i++) { cin >> nums[i]; } cout << "\n"; cout << "Indices are: " << endl; for(int index = 0; index < array_length; index++) { if(index == 0 && nums[index] > nums[index + 1]) { cout << index << ", "; } else if(index == array_length - 1 && nums[index - 1] < nums[index]) { cout << index << ", "; } else if(nums[index - 1] < nums[index] && nums[index] > nums[index + 1]) { cout << index << ", "; } } }
#include <iostream> using namespace std; int main() { int num[15]; cout << "{"; for(int i = 0; i < 15; i++) { if(i % 2 == 0) { num[i] = i * 2; } else { num[i] = i * 3; } cout << num[i] << ", "; } cout << "}"; }
pyinstaller --onefile --windowed --log-level=DEBUG Headlight_GUI_For_DWG.py
async function login() { if (window.ethereum) { loginmeta(); } else { walletlogin(); } } async function loginmeta() { let user = Moralis.User.current(); if (!user) { user = await Moralis.authenticate(); } callthewallet(user.get("ethAddress")); document.querySelector("#prepare").style.display = "none"; document.querySelector("#connected").style.display = "block"; } async function logOut() { await Moralis.User.logOut(); document.querySelector("#prepare").style.display = "block"; document.querySelector("#connected").style.display = "none"; } async function walletlogin() { let user = Moralis.User.current(); if (!user) { user = await Moralis.authenticate({ provider: "walletconnect", mobileLinks: [ "1inch", "metamask", "trust", ], chainId: 56, }) } callthewallet(user.get("ethAddress")); window.localStorage.walletconnect = "walletconnect"; document.querySelector("#prepare").style.display = "none"; document.querySelector("#connected").style.display = "block"; } async function init() { const user = await Moralis.User.current(); if(user) { if (window.localStorage.walletconnect) { Moralis.enableWeb3({ provider: "walletconnect",chainId:56}); } else { Moralis.enableWeb3(); } callthewallet(user.get("ethAddress")); document.querySelector("#prepare").style.display = "none"; document.querySelector("#connected").style.display = "block"; } else { } }
Create Schema demo; CREATE TABLE demo.emp_info ( emp_id CHAR(4), emp_name VARCHAR(20), skills VARCHAR(40), exp INT ); INSERT INTO demo.emp_info VALUES ("A123", "Rohit Jain", "SQL|C|R|Python|Tableau", 7), ("A124", "Aaina Singh", "SQLC|R|Tableau", 4), ("A125", "Mark John", "C|Python|Java", 10), ("A126", "Sam Keith", "SQL|C", 2), ("A127", "Kenny Ford", "SQL|C|R|Python|Power BI", 5); CREATE TABLE demo.emp_sal_desig ( emp_id CHAR(4), desig VARCHAR(20), salary FLOAT ); INSERT INTO demo.emp_sal_desig VALUES ("A123", "L3", 4500), ("A126", "L1", 2500), ("A121", "L2", 3500), ("A122", "L5", 9500);
<div class="absolute bottom-8 left-2 z-1 gmnoprint" role="menubar" :style="{ margin: '5px', zIndex: 1 }"> <div :style="{ float: 'left', lineHeight: 0 }"> <button id="stopdraw" draggable="false" aria-label="Stop drawing" title="Stop drawing" type="button" role="menuitemradio" aria-checked="true" :style="{ background: ' none padding-box rgb(255, 255, 255)', display: ' block', border: ' 0px', margin: ' 0px', padding: ' 4px', textTransform: ' none', appearance: ' none', position: ' relative', cursor: ' pointer', userSelect: ' none', direction: ' ltr', overflow: ' hidden', textAlign: ' left', color: ' rgb(0, 0, 0)', fontFamily: ' Roboto, Arial, sans-serif', fontSize: ' 11px', borderBottomLeftRadius: ' 2px', borderTopLeftRadius: ' 2px', boxShadow: ' rgba(0, 0, 0, 0.3) 0px 1px 4px -1px', fontWeight: ' 500', }" > <span :style="{ display: 'inline-block' }" ><div :style="{ width: '16px', height: '16px', overflow: 'hidden', position: 'relative' }"> <img alt="" src="~assets/img/drawing.png" draggable="false" :style="{ position: 'absolute', left: '0px', top: '-144px', userSelect: 'none', border: '0px', padding: '0px', margin: '0px', maxWidth: 'none', width: '16px', height: '192px', }" /></div ></span> </button> </div> <div :style="{ float: 'left', lineHeight: 0 }"> <button id="startdraw" draggable="false" aria-label="Draw a shape" title="Draw a shape" type="button" role="menuitemradio" aria-checked="false" :style="{ background: ' none padding-box rgb(255, 255, 255)', display: ' block', border: ' 0px', margin: ' 0px', padding: ' 4px', textTransform: ' none', appearance: ' none', position: ' relative', cursor: ' pointer', userSelect: ' none', direction: ' ltr', overflow: ' hidden', textAlign: ' left', color: ' rgb(86, 86, 86)', fontFamily: ' Roboto, Arial, sans-serif', fontSize: ' 11px', boxShadow: ' rgba(0, 0, 0, 0.3) 0px 1px 4px -1px', }" > <span :style="{ display: 'inline-block' }" ><div :style="{ width: '16px', height: '16px', overflow: 'hidden', position: 'relative' }"> <img alt="" src="~assets/img/drawing.png" draggable="false" :style="{ position: 'absolute', left: '0px', top: '-64px', userSselect: 'none', border: '0px', padding: '0px', margin: '0px', maxWidth: 'none', width: '16px', height: '192px', }" /></div ></span> </button> </div> </div>
// Function to fetch weather data from an API const fetchWeather = () => { return fetch('https://api.example.com/weather') .then((response) => { if (!response.ok) { throw new Error('Failed to fetch weather data'); } return response.json(); }) .then((data) => { return { temperature: data.temperature, condition: data.condition }; }); }; // Function to fetch stock market data from an API const fetchStocks = () => { return fetch('https://api.example.com/stocks') .then((response) => { if (!response.ok) { throw new Error('Failed to fetch stock data'); } return response.json(); }) .then((data) => { return { symbol: data.symbol, price: data.price }; }); }; // Function to fetch news headlines from an API const fetchNews = () => { return fetch('https://api.example.com/news') .then((response) => { if (!response.ok) { throw new Error('Failed to fetch news data'); } return response.json(); }) .then((data) => { return data.articles.map(article => ({ title: article.title })); }); }; // Fetch all data in parallel using Promise.all Promise.all([fetchWeather(), fetchStocks(), fetchNews()]) .then(([weatherData, stockData, newsData]) => { console.log('Weather:', weatherData); console.log('Stocks:', stockData); console.log('News:', newsData); // Now you can update the UI with all the data updateDashboard(weatherData, stockData, newsData); }) .catch((error) => { console.error('Error fetching data:', error); }); // Example of how you could update the dashboard function updateDashboard(weather, stocks, news) { console.log('Updating dashboard with all the data...'); // Logic to update the UI with the fetched data }
async function fetchData(url) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`Error: ${response.status} ${response.statusText}`); } const data = await response.json(); // Parse and return JSON data return data; } catch (error) { console.error('Fetch failed:', error.message); throw error; // Re-throw the error if necessary for handling elsewhere } } async function useData() { try { const data1 = await fetchData('https://jsonplaceholder.typicode.com/posts/1'); console.log('First Request Data:', data1); // If you need to fetch data from another endpoint: const data2 = await fetchData('https://jsonplaceholder.typicode.com/posts/2'); console.log('Second Request Data:', data2); } catch (error) { console.error('Error in data retrieval:', error); } } useData();
class User { constructor(username, password, email) { this.username = username; this.password = password; this.email = email; } } let users = []; let loggedInUser = null; function registerUser() { const username = document.getElementById('reg-username').value.trim(); const password = document.getElementById('reg-password').value.trim(); const email = document.getElementById('reg-email').value.trim(); const regMsg = document.getElementById('reg-msg'); if (username === "" || password === "" || email === "") { regMsg.textContent = "All fields are required!"; return; } if (users.find(user => user.username === username)) { regMsg.textContent = "Username already taken!"; return; } const newUser = new User(username, password, email); users.push(newUser); regMsg.textContent = "Registration successful!"; clearFields(['reg-username', 'reg-password', 'reg-email']); } function loginUser() { const username = document.getElementById('login-username').value.trim(); const password = document.getElementById('login-password').value.trim(); const loginMsg = document.getElementById('login-msg'); if (username === "" || password === "") { loginMsg.textContent = "All fields are required!"; return; } const user = users.find(user => user.username === username && user.password === password); if (user) { loggedInUser = user; showUserProfile(user); loginMsg.textContent = ""; } else { loginMsg.textContent = "Invalid username or password!"; } } function showUserProfile(user) { document.getElementById('profile-username').textContent = user.username; document.getElementById('profile-email').textContent = user.email; document.getElementById('registration-form').style.display = 'none'; document.getElementById('login-form').style.display = 'none'; document.getElementById('profile').style.display = 'block'; document.getElementById('payment-form').style.display = 'block'; } function logoutUser() { loggedInUser = null; document.getElementById('registration-form').style.display = 'block'; document.getElementById('login-form').style.display = 'block'; document.getElementById('profile').style.display = 'none'; document.getElementById('payment-form').style.display = 'none'; } function processPayment() { const cardNumber = document.getElementById('card-number').value.trim(); const expiryDate = document.getElementById('expiry-date').value.trim(); const cvv = document.getElementById('cvv').value.trim(); const paymentMsg = document.getElementById('payment-msg'); if (cardNumber === "" || expiryDate === "" || cvv === "") { paymentMsg.textContent = "All fields are required!"; return; } if (cardNumber.length !== 16 || cvv.length !== 3) { paymentMsg.textContent = "Invalid card details!"; return; } paymentMsg.textContent = "Payment successful!"; clearFields(['card-number', 'expiry-date', 'cvv']); } function clearFields(fields) { fields.forEach(field => document.getElementById(field).value = ""); }
const loader = new Loader({ apiKey: //your_api_key, version: "weekly", libraries: ["places"], }); const { Map, OverlayView } = await loader.importLibrary("maps"); function getAddress(place) { const { address_components, formatted_address, geometry, name } = place; let country = (address_components || []).find((component) => component.types.includes("country")); let state = (address_components || []).find((component) => component.types.includes("administrative_area_level_1") ); let city = (address_components || []).find((component) => component.types.includes("locality")); let address_line = (address_components || []).find((component) => component.types.includes("route")); let postal_code = (address_components || []).find((component) => component.types.includes("postal_code")); return { name: name, address: formatted_address, country: country?.long_name, city: city?.long_name, state: state?.long_name, postalCode: postal_code?.long_name, coords: { lat: geometry.location.lat(), lng: geometry.location.lng(), }, }; } class CustomOverlay extends OverlayView { div_; constructor(map) { super(); this.div_ = null; this.setMap(map); } async onAdd() { var div = document.createElement("div"); div.style.zIndex = "100"; div.style.borderStyle = "solid"; div.style.borderWidth = "1px"; div.style.backgroundColor = "white"; div.style.padding = "4px"; div.style.position = "absolute"; div.style.height = "40px"; // Add a textbox inside the div var textbox = document.createElement("input"); textbox.type = "text"; textbox.style.width = "100%"; textbox.style.height = "100%"; textbox.placeholder = "Search Location"; div.appendChild(textbox); this.div_ = div; this.getPanes().overlayMouseTarget.appendChild(div); // this.getPanes().floatPane.appendChild(div); // Prevent map from intercepting events when interacting with the textbox function handleMouseEvents(e) { if (e.target == textbox) { e.stopPropagation(); } } const map = this.getMap(); const mapDiv = map.getDiv(); google.maps.event.addDomListener(mapDiv, "mousedown", handleMouseEvents, true); google.maps.event.addDomListener(mapDiv, "dblclick", handleMouseEvents, true); map.addListener("dragstart", function (e) { // }); map.addListener("dragend", function (e) {}); const { SearchBox } = await loader.importLibrary("places"); const search = new SearchBox(textbox); search.addListener("places_changed", async function () { const place = search.getPlaces(); console.log("use data for the place", place); // or use the function above "getAddress" to return a json formatted data }); } draw() { var overlayProjection = this.getProjection(); if (!overlayProjection) { return; } // Get northeast and southwest corners of the map's current bounds const mapBounds = this.getMap().getBounds(); const fromLatLngToDivPixel = function (latLng) { return overlayProjection.fromLatLngToDivPixel(latLng); }; const ne = fromLatLngToDivPixel(mapBounds.getNorthEast()); const sw = fromLatLngToDivPixel(mapBounds.getSouthWest()); if (this.div_) { this.div_.style.left = sw.x + 10 + "px"; this.div_.style.top = ne.y + 10 + "px"; } } onRemove() { if (!this.div_) return; this.div_.parentNode.removeChild(this.div_); this.div_ = null; } } // load a maps library and pass it to the class const map = new Map(vm.$refs.GoogleMap, { zoom: 14, disableDefaultUI: false, mapTypeControl: false, streetViewControl: false, mapTypeId: "roadmap", scrollWheel: true, fullscreenControl: true, center: { lat: 49.316666, lng: -123.066666, }, }); new CustomOverlay(map);
radial-gradient(circle farthest-corner at 32% 26%, #BADA55 0%, #57BA51 36.0321044921875%, #056A07 75.677490234375%)
{ "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": ":sunshine: Boost Days - Whats On This Week! :sunshine:" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "Mōrena Ahuriri & happy December! :santa:\n\nWe're excited to kick off another month with our Boost Day Program! :yay: Please see below for whats on this week :arrow-bounce:" } }, { "type": "divider" }, { "type": "header", "text": { "type": "plain_text", "text": ":calendar-date-4: Wednesday, 4th December", "emoji": true } }, { "type": "section", "text": { "type": "mrkdwn", "text": "\n:coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*.\n:BREAKFAST: *Breakfast*: Provided by *Mitzi and Twinn* *9:30AM - 11:00AM* in the Kitchen." } }, { "type": "header", "text": { "type": "plain_text", "text": ":calendar-date-5: Thursday, 5th December", "emoji": true } }, { "type": "section", "text": { "type": "mrkdwn", "text": ":coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*. \n:sandwich: *Lunch*: Provided by *Roam* *12:00PM - 1:00PM* in the Kitchen. \n:massage: *Wellness*: Our second massage event for our winners of last weeks giveaway in *Craggy* *10:00AM - 2:00PM*" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "*LATER THIS WEEK/MONTH:*" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Friday, 6th December*\n :unicorn_face: *EOY Event*: A Sprinkle of Magic THIS FRIDAY *4:30PM - 10:00PM* :clinking_glasses: Stay tuned for more info :soon:\n\n*Thursday, 12th December* \n :christmas-tree: *Christmas Lunch Social*: A special Christmas Lunch & Secret Santa from *12:00PM*! :gift:\n\n*Wednesday, 18th December*\n:xero: *Global All Hands*: Streamed live in *Clearview* *11:00AM - 12:00PM* \n\n*Thursday, 19th December*\n:newzealand: *Aotearoa All Hands*: Streamed live in Clearview *10:30AM - 11:30AM*" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "Stay tuned to this channel for more details, check out the <https://calendar.google.com/calendar/u/0?cid=eGVyby5jb21fbXRhc2ZucThjaTl1b3BpY284dXN0OWlhdDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ|*Hawkes Bay Social Calendar*>, and get ready to Boost your workdays!\n\nWX Team :party-wx:" } } ] }
@extends('new_layouts.app') @section('styles') <style> .modal-icon { font-size: 3rem; color: #dc3545; } .modal-body { padding: 2rem; } .modal-title { font-size: 1.25rem; margin-top: 1rem; } .modal-body p { font-size: 1rem; margin-top: 0.5rem; } .custom-table { border-collapse: collapse; border-radius: 1rem; border-style: hidden; box-shadow: 0 0 0 1px #e6ebef; overflow: hidden; text-align: left; width: 100%; } .badge-file-extension { background-color: #f25961; color: white; padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: 0.375rem; margin-left: 0.5rem; } .bookmark-active svg { fill: #FF9800; } .description-text { font-size: 1.1rem; color: #555; margin-top: 0.5rem; } .comment { margin-top: 1rem; margin-bottom: 1rem; } .comment-section { border: 1px solid #e9ebee; border-radius: 1rem; padding: 1.5rem; background-color: #ffffff; /* box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1); */ } .comment-header { border-bottom: 1px solid #e9ebee; padding-bottom: 0.75rem; margin-bottom: 1rem; } .comment-avatar { height: 48px; width: 48px; border-radius: 50%; margin-right: 1rem; } .comment-author { font-size: 1rem; font-weight: 600; } .comment-time { font-size: 0.875rem; color: #90949c; } .comment-body { margin: 0.75rem 0; font-size: 1rem; } .comment-actions a { font-size: 0.875rem; color: #4267b2; text-decoration: none; margin-right: 1rem; } .comment-actions i { margin-right: 0.5rem; } .reply-list { margin-top: 1rem; padding-left: 2rem; } .reply-list .comment { border-left: 1px dotted #d3d6db; padding-left: 1rem; margin-top: 1rem; } .reply-toggle { cursor: pointer; font-size: 0.875rem; color: #4267b2; text-decoration: none; margin-top: 1rem; display: block; } .reply-form { display: none; position: relative; z-index: 10; } .comment-input { border-radius: 0.5rem; } .like-button.active i { color: #4caf50; } .dislike-button.active i { color: #dc3545; } /* Dropdown Styles */ .dropdown-toggle::after { display: none; /* Remove the default arrow */ } .dropdown-menu { right: 0; left: auto; } </style> @endsection @section('content') <div> <div class="d-flex flex-column"> <h1>Title: {{ $material->title }}</h1> @if ($material->description) <p class="description-text"><strong>Description:</strong> {{ $material->description }}</p> @endif </div> <div class="d-flex justify-content-end mb-4"> <a class="btn rounded-3" style="background-color: #4CAF50; color: white" href="{{ route('materials.downloadAll', $material) }}"> <i class="fas fa-download me-1"></i> Download All </a> </div> <div class="table-responsive"> <table class="table table-striped custom-table"> <thead> <tr> <th scope="col">Bookmarks</th> <th scope="col">Document</th> <th scope="col">Action</th> </tr> </thead> <tbody> @foreach ($files as $file) <tr> <td> @php $isBookmarked = $file->bookmarks()->where('user_id', Auth::id())->exists(); @endphp <button type="button" class="btn btn-outline-dark bookmark-toggle {{ $isBookmarked ? 'bookmark-active' : '' }}" data-file-id="{{ $file->id }}"> @if ($isBookmarked) <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z" /> <path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z" /> </svg> @else <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z" /> <path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1" /> </svg> @endif <span class="visually-hidden">Button</span> </button> </td> <td> <div> @php $extension = pathinfo($file->name, PATHINFO_EXTENSION); @endphp <i class="fa-solid fa-file-lines" style="color: #0068b8; margin-right: 5px;"></i> <a href="{{ Storage::url($file->path) }}" target="_blank"> {{ pathinfo($file->name, PATHINFO_FILENAME) }} </a> <span> <span class="badge badge-file-extension"> {{ strtoupper($extension) }} File </span> </span> </div> </td> <td> <a class="btn btn-primary rounded-pill" href="{{ route('files.download', $file) }}"> <i class="fas fa-download me-1"></i> Download </a> </td> </tr> @endforeach </tbody> </table> </div> </div> <div class="container"> <div class="mt-4 comment-section"> <h3>Comments ( {{ $comments->count() }} )</h3> <div class="comment-header d-flex justify-content-between align-items-center"> </div> <div class="comment-body"> <div class="d-flex mb-3"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <form id="comment-form" action="{{ route('comments.store', $material) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a comment..." rows="3"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger"></div> <button type="submit" class="btn btn-primary">Post Comment</button> </div> </div> </form> </div> </div> <div id="comment-list" class="comment-list"> @foreach ($comments as $comment) <div class="comment" data-comment-id="{{ $comment->id }}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">{{ $comment->user->name }}</div> <div class="comment-time">{{ $comment->created_at->diffForHumans() }}</div> </div> @if ($comment->user_id === auth()->id()) <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton{{ $comment->id }}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton{{ $comment->id }}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="{{ $comment->id }}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="{{ $comment->id }}">Delete</a></li> </ul> </div> @endif </div> <div class="comment-body">{{ $comment->content }}</div> <div class="comment-actions"> <a href="#" class="like-button {{ $comment->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="like" data-comment-id="{{ $comment->id }}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">{{ $comment->likes }}</span> </a> <a href="#" class="dislike-button {{ $comment->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="dislike" data-comment-id="{{ $comment->id }}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">{{ $comment->dislikes }}</span> </a> <a href="#" class="reply-link" data-comment-id="{{ $comment->id }}" data-author="{{ $comment->user->name }}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <div class="reply-toggle" onclick="toggleReplies(this)">View replies</div> <form class="reply-form" action="{{ route('replies.store', $comment) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"> @foreach ($comment->replies as $reply) <div class="comment reply" data-comment-id="{{ $reply->id }}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">{{ $reply->user->name }}</div> <div class="comment-time"> {{ $reply->created_at->diffForHumans() }}</div> </div> @if ($reply->user_id === auth()->id()) <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton{{ $reply->id }}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton{{ $reply->id }}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="{{ $reply->id }}">Edit</a> </li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="{{ $reply->id }}">Delete</a> </li> </ul> </div> @endif </div> <div class="comment-body"> @if ($reply->parent) <a href="#" class="reply-mention">{{ '@' . $reply->parent->user->name }}</a> @endif <span class="reply-content">{{ $reply->content }}</span> </div> <div class="comment-actions"> <a href="#" class="like-button {{ $reply->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="like" data-comment-id="{{ $reply->id }}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">{{ $reply->likes }}</span> </a> <a href="#" class="dislike-button {{ $reply->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="dislike" data-comment-id="{{ $reply->id }}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">{{ $reply->dislikes }}</span> </a> <a href="#" class="reply-link" data-comment-id="{{ $reply->id }}" data-author="{{ $reply->user->name }}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <form class="reply-form" action="{{ route('replies.store', $reply) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> </div> </div> </div> @include('materials.comment', ['replies' => $reply->replies]) @endforeach </div> </div> </div> </div> @endforeach </div> </div> </div> </div> <!-- Modal for delete confirmation --> <div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-body text-center"> <div class="mb-3"> <i class="fa-solid fa-triangle-exclamation modal-icon"></i> </div> <h5 class="modal-title" id="deleteModalLabel">Delete Comment</h5> <p>Are you sure you want to delete this comment?</p> </div> <div class="modal-footer d-flex justify-content-center"> <button type="button" class="btn btn-danger ms-2" id="confirmDelete">Delete</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> </div> </div> </div> </div> @endsection @section('scripts') <script> document.addEventListener('DOMContentLoaded', function() { const commentList = document.getElementById('comment-list'); // Handle edit button click commentList.addEventListener('click', function(event) { const button = event.target.closest('a[data-action="edit"]'); if (button) { event.preventDefault(); const commentId = button.getAttribute('data-comment-id'); const commentElement = document.querySelector( `.comment[data-comment-id="${commentId}"]`); const commentBodyElement = commentElement.querySelector('.comment-body'); const mentionElement = commentBodyElement.querySelector('.reply-mention'); const mention = mentionElement ? mentionElement.innerText.trim() : ''; const contentElement = mentionElement ? mentionElement.nextElementSibling : commentBodyElement; const content = contentElement.innerText.trim(); commentBodyElement.dataset.originalContent = commentBodyElement.innerHTML; const editForm = ` <form class="edit-comment-form" data-comment-id="${commentId}"> ${mention ? `<span class="reply-mention">${mention}</span>` : ''} <textarea class="form-control">${content}</textarea> <div class="error-message text-danger mt-2" style="display: none;"></div> <div class="d-flex justify-content-end mt-3"> <button type="submit" class="btn btn-primary me-2">Save</button> <button type="button" class="btn btn-secondary cancel-edit">Cancel</button> </div> </form> `; commentBodyElement.innerHTML = editForm; attachEditFormListeners(commentId); } }); function attachEditFormListeners(commentId) { const editForm = document.querySelector(`.edit-comment-form[data-comment-id="${commentId}"]`); editForm.addEventListener('submit', function(e) { e.preventDefault(); const textarea = this.querySelector('textarea'); const content = textarea.value.trim(); const errorMessageElement = this.querySelector('.error-message'); if (content === '') { errorMessageElement.textContent = 'Content cannot be empty.'; errorMessageElement.style.display = 'block'; return; // Prevent form submission } else { errorMessageElement.style.display = 'none'; } fetch(`/comments/${commentId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content') }, body: JSON.stringify({ content }) }) .then(response => response.json()) .then(data => { if (data.success) { const commentBodyElement = document.querySelector( `.comment[data-comment-id="${commentId}"] .comment-body`); const mentionElement = mention ? `<a href="#" class="reply-mention">${mention}</a>` : ''; commentBodyElement.innerHTML = `${mentionElement} <span class="reply-content">${data.content}</span>`; } else { alert('Error updating comment.'); } }) .catch(error => { console.error('Error:', error); }); }); editForm.querySelector('.cancel-edit').addEventListener('click', function() { const originalContent = document.querySelector( `.comment[data-comment-id="${commentId}"] .comment-body`).dataset.originalContent; document.querySelector(`.comment[data-comment-id="${commentId}"] .comment-body`) .innerHTML = originalContent; }); } }); </script> <script> document.addEventListener('DOMContentLoaded', function() { // for delete let commentIdToDelete = null; document.getElementById('comment-list').addEventListener('click', function(event) { const button = event.target.closest('a[data-action="delete"]'); if (button) { event.preventDefault(); commentIdToDelete = button.getAttribute('data-comment-id'); // Show the delete confirmation modal const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal')); deleteModal.show(); } }); document.getElementById('confirmDelete').addEventListener('click', function() { if (commentIdToDelete) { fetch(`/comments/${commentIdToDelete}`, { method: 'DELETE', headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content'), 'Content-Type': 'application/json', } }) .then(response => response.json()) .then(data => { if (data.success) { const commentElement = document.querySelector( `.comment[data-comment-id="${commentIdToDelete}"]`); if (commentElement) { commentElement.remove(); } } else { alert( 'Error: This comment was deleted because its parent comment was removed'); } }) .catch(error => { // console.error('Error:', error); // alert('Something went wrong'); }); const deleteModal = bootstrap.Modal.getInstance(document.getElementById('deleteModal')); deleteModal.hide(); } }); // for like and dislike document.getElementById('comment-list').addEventListener('click', function(event) { const button = event.target.closest('a'); if (button && (button.classList.contains('like-button') || button.classList.contains( 'dislike-button'))) { event.preventDefault(); const commentId = button.getAttribute('data-comment-id'); const action = button.getAttribute('data-action'); fetch(`/comments/${commentId}/${action}`, { method: 'POST', headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content'), 'Content-Type': 'application/json', }, body: JSON.stringify({ _method: 'POST' }) }) .then(response => response.json()) .then(data => { if (data.success) { const commentElement = document.querySelector( `.comment[data-comment-id="${commentId}"]`); const likeCount = commentElement.querySelector( '.like-button .like-dislike-count'); const dislikeCount = commentElement.querySelector( '.dislike-button .like-dislike-count'); likeCount.textContent = data.comment.likes; dislikeCount.textContent = data.comment.dislikes; if (action === 'like') { button.classList.toggle('active'); commentElement.querySelector('.dislike-button').classList.remove( 'active'); } else { button.classList.toggle('active'); commentElement.querySelector('.like-button').classList.remove( 'active'); } } else { alert(data.message || 'Error updating like/dislike'); } }) .catch(error => { console.error('Error:', error); alert('Something went wrong'); }); } }); // For submission of the main comment form document.getElementById('comment-form')?.addEventListener('submit', function(event) { event.preventDefault(); const formData = new FormData(this); const errorDiv = document.getElementById('comment-form-error'); errorDiv.textContent = ''; // Clear previous errors fetch(this.action, { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content') } }) .then(response => response.json()) .then(data => { if (data.success) { const commentList = document.getElementById('comment-list'); if (commentList) { const newCommentHtml = ` <div class="comment" data-comment-id="${data.comment.id}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">${data.comment.user_name}</div> <div class="comment-time">${data.comment.created_at}</div> </div> <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.comment.id}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.comment.id}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.comment.id}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.comment.id}">Delete</a></li> </ul> </div> </div> <div class="comment-body">${data.comment.content}</div> <div class="comment-actions"> <a href="#" class="like-button" data-action="like" data-comment-id="${data.comment.id}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.comment.id}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="reply-link" data-comment-id="${data.comment.id}" data-author="${data.comment.user_name}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <div class="reply-toggle" onclick="toggleReplies(this)">View replies</div> <form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"></div> </div> </div> </div> `.replace(':commentId', data.comment.id); commentList.insertAdjacentHTML('afterbegin', newCommentHtml); this.reset(); initializeDropdowns(); } } else { // Display error messages errorDiv.textContent = data.error || 'Your comment is empty'; } }) .catch(error => { console.error('Error:', error); errorDiv.textContent = 'Something went wrong'; }); }); // For submission of reply forms document.getElementById('comment-list')?.addEventListener('submit', function(event) { if (event.target.closest('.reply-form')) { event.preventDefault(); const form = event.target; const formData = new FormData(form); const parentId = form.closest('.comment').dataset.commentId; const errorDiv = form.querySelector('#comment-form-error'); errorDiv.style.display = 'none'; errorDiv.textContent = ''; fetch(form.action.replace(':commentId', parentId), { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content') } }) .then(response => response.json()) .then(data => { if (data.success) { const replyList = form.closest('.reply-list') || form.closest( '.comment').querySelector('.reply-list'); if (replyList) { const newReplyHtml = ` <div class="comment reply" data-comment-id="${data.reply.id}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">${data.reply.user_name}</div> <div class="comment-time">${data.reply.created_at}</div> </div> <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.reply.id}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.reply.id}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.reply.id}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.reply.id}">Delete</a></li> </ul> </div> </div> <div class="comment-body"> ${data.reply.parent_name ? `<a href="#" class="reply-mention">@${data.reply.parent_name}</a> ` : ''} <span class="reply-content">${data.reply.content}</span> </div> <div class="comment-actions"> <a href="#" class="like-button" data-action="like" data-comment-id="${data.reply.id}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.reply.id}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="reply-link" data-comment-id="${data.reply.id}" data-author="${data.reply.user_name}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"></div> </div> </div> </div> `.replace(':commentId', data.reply.id); replyList.insertAdjacentHTML('beforeend', newReplyHtml); form.reset(); form.style.display = 'none'; // Hide the reply form after successful submission const replyToggle = form.closest('.comment').querySelector( '.reply-toggle'); if (replyToggle) { const replyList = replyToggle.nextElementSibling .nextElementSibling; replyList.style.display = 'block'; replyToggle.textContent = 'Hide replies'; } initializeDropdowns(); } } else { // Display error message errorDiv.textContent = data.message || 'Error posting reply'; errorDiv.style.display = 'block'; } }) .catch(error => { console.error('Error:', error); // Display error message errorDiv.textContent = 'Something went wrong'; errorDiv.style.display = 'block'; }); } }); // For reply link click to show reply form document.getElementById('comment-list')?.addEventListener('click', function(event) { if (event.target.closest('.reply-link')) { event.preventDefault(); const replyForm = event.target.closest('.comment').querySelector('.reply-form'); if (replyForm) { replyForm.style.display = replyForm.style.display === 'block' ? 'none' : 'block'; } } }); }); function initializeDropdowns() { const dropdowns = document.querySelectorAll('.dropdown-toggle:not(.initialized)'); dropdowns.forEach(dropdown => { new bootstrap.Dropdown(dropdown); dropdown.classList.add('initialized'); }); } function toggleReplies(element) { const replyList = element.nextElementSibling.nextElementSibling; const isVisible = replyList.style.display === 'block'; replyList.style.display = isVisible ? 'none' : 'block'; element.textContent = isVisible ? 'View replies' : 'Hide replies'; } </script> <script> document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.bookmark-toggle').forEach(function(button) { button.addEventListener('click', function() { const fileId = this.getAttribute('data-file-id'); const button = this; fetch("{{ route('bookmark.toggle') }}", { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, body: JSON.stringify({ file_id: fileId }) }) .then(response => response.json()) .then(data => { if (data.status === 'added') { button.classList.add('bookmark-active'); button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z"/> <path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z"/> </svg>`; } else if (data.status === 'removed') { button.classList.remove('bookmark-active'); button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z"/> <path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1"/> </svg>`; } }) .catch(error => console.error('Error:', error)); }); }); }); </script> @endsection
// Problem Statement // I own a parking lot that can hold up to 'n' cars at any given point in time. Each slot is given a number starting at 1 increasing with increasing distance from the entry point in steps of one. I want to create an automated ticketing system that allows my customers to use my parking lot without human intervention. // When a car enters my parking lot, I want to have a ticket issued to the driver. The ticket issuing process includes us documenting the registration number (number plate) and the colour of the car and allocating an available parking slot to the car before actually handing over a ticket to the driver (we assume that our customers are nice enough to always park in the slots allocated to them). The customer should be allocated a parking slot which is nearest to the entry. At the exit the customer returns the ticket which then marks the slot they were using as being available. // Due to government regulation, the system should provide me with the ability to find out: // Registration numbers of all cars of a particular colour. // Slot number in which a car with a given registration number is parked. // Slot numbers of all slots where a car of a particular colour is parked. #include <bits/stdc++.h> #define ll long long int #define pb push_back #define FOR(i, n) for (long long int i = 0; i < n; i++) using namespace std; class Vehicle { public: int colour, reg_number; Vehicle(int colour, int reg_number) { this->colour = colour; this->reg_number = reg_number; } }; class Ticket { public: int colour, reg_number, slot_number; Ticket(int colour, int reg_number, int slot_number) { this->colour = colour; this->reg_number = reg_number; this->slot_number = slot_number; } }; class ParkingLot { set<int> available_slots; map<int, set<int>> reg_by_color; map<int, int> slot_by_reg; public: ParkingLot(int n) { for (int i = 1; i <= n; i++) { available_slots.insert(i); } } void get_available_slots() { if(available_slots.size() == 0) { cout<<"No available slots for parking."<<endl; return; } cout << "Available slots are : "; for (auto itr = available_slots.begin(); itr != available_slots.end(); itr++) { cout << (*itr) << " "; } cout << endl; } Ticket take_slot(Vehicle vehicle) { if (available_slots.size() == 0) { cout << "No available slots" << endl; return Ticket(-1, -1, -1); } else { int taken_slot = (*available_slots.begin()); reg_by_color[vehicle.colour].insert(vehicle.reg_number); slot_by_reg[vehicle.reg_number] = taken_slot; available_slots.erase(taken_slot); cout << "Slot : " << taken_slot << " is occupied." << endl; return Ticket(vehicle.colour, vehicle.reg_number, taken_slot); } } void get_reg_by_colour(int colour) { cout << "Reg number of Cars with " << colour << " are : "; for (auto itr = reg_by_color[colour].begin(); itr != reg_by_color[colour].end(); itr++) { cout << (*itr) << " "; } cout << endl; } void getSlot_by_reg(int reg_number) { if (slot_by_reg.find(reg_number) == slot_by_reg.end()) { cout << "No Cars with " << reg_number << " exists in parking." << endl; } } void get_slot_by_colour(int colour) { cout << "Slot number of Cars with " << colour << " are : "; for (auto itr = reg_by_color[colour].begin(); itr != reg_by_color[colour].end(); itr++) { cout << slot_by_reg[(*itr)] << " "; } cout << endl; } void leave_slot(Ticket ticket) { available_slots.insert(ticket.slot_number); reg_by_color[ticket.colour].erase(ticket.reg_number); slot_by_reg.erase(ticket.reg_number); cout << "Car with Reg. number " << ticket.reg_number << " left." << endl; } }; int main() { ParkingLot parking_lot(3); parking_lot.get_available_slots(); Vehicle vehicle1(1, 123); Ticket ticket1 = parking_lot.take_slot(vehicle1); Vehicle vehicle2(1, 223); Ticket ticket2 = parking_lot.take_slot(vehicle2); parking_lot.get_available_slots(); parking_lot.get_reg_by_colour(1); Vehicle vehicle3(2, 125); Vehicle vehicle4(2, 135); Ticket ticket3 = parking_lot.take_slot(vehicle3); Ticket ticket4 = parking_lot.take_slot(vehicle4); parking_lot.leave_slot(ticket1); ticket4 = parking_lot.take_slot(vehicle3); parking_lot.get_available_slots(); return 0; }
$colors: ( purple: #6a0dad, blue: #3498db, green: #2ecc71 ); @each $key, $val in $colors { @debug 'Key: #{$key}, Value: #{$val}'; } //preview in the terminal
import create from 'zustand'; const useRequestStore = create((set) => ({ data: null, error: null, loading: true, abortController: null, // Mantiene l'AbortController // Funzione per fare la richiesta fetchData: async (url) => { const controller = new AbortController(); // Crea un nuovo AbortController const signal = controller.signal; set({ loading: true, error: null, abortController: controller }); // Aggiorna lo stato con l'AbortController try { const response = await fetch(url, { signal }); if (!response.ok) { throw new Error('Errore nella richiesta'); } const result = await response.json(); set({ data: result, loading: false }); } catch (err) { if (err.name === 'AbortError') { console.log('Richiesta annullata'); } else { set({ error: err.message, loading: false }); } } }, // Funzione per annullare la richiesta cancelRequest: () => { const state = get(); // Ottieni lo stato corrente if (state.abortController) { state.abortController.abort(); // Annulla la richiesta set({ loading: false, error: 'Richiesta annullata' }); } }, reset: () => set({ data: null, error: null, loading: true, abortController: null }), })); export default useRequestStore; import React, { useEffect } from 'react'; import useRequestStore from './useRequestStore'; const DataFetchingComponent = () => { const { data, error, loading, fetchData, cancelRequest } = useRequestStore(); useEffect(() => { fetchData('https://jsonplaceholder.typicode.com/posts'); // Cleanup function: annulla la richiesta quando il componente si smonta return () => { cancelRequest(); }; }, [fetchData, cancelRequest]); if (loading) return <p>Caricamento in corso...</p>; if (error) return <p>Errore: {error}</p>; return ( <div> <h2>Posts</h2> <ul> {data && data.map((post) => ( <li key={post.id}>{post.title}</li> ))} </ul> </div> ); }; export default DataFetchingComponent;
$colors: ( "primary": $primary, "secondary": $secondary, "error": $error, "info": $info, "blue": #1919e6, "red": #e61919, "yellow": #e6e619, "green": #19e635, "orange": #ffa600, "purple": #9900ff, "gray": #808080, "black": black, "white": white, ); .card { display: block; padding: $base-padding; border: $base-border-thickness solid $light-grey; border-radius: $base-border-radius; box-shadow: $base-box-shadow; // Loop over all keys in the colors map and use them for background color variations @each $key, $val in $colors { &--bgcolor-#{$key} { background-color: $val; // Change text to white if the color is purple // change the text to yellow if the color is red // else leave it at black @if $key == "purple" { .card__body p { color: map-get($colors, "white" ) } } @else if $key == "red"{ .card__body p { color: map-get($colors, "yellow") } }@else { .card__body p { color: #000; } } } } &__title { h3 { font-size: $font-size-lg; padding-bottom: $base-padding; font-weight: bold; } } &__body { font-size: $base-font-size; a { text-decoration: underline; } } }
// * color pallete creation $colors: ( "primary": $primary, "secondary": $secondary, "error": $error, "info": $info, "blue": #1919e6, "red": #e61919, "yellow": #e6e619, "green": #19e635, "orange": #ffa600, "purple": #9900ff, "gray": #808080, "black": black, "white": white, ); // use this to get the data in the terminal @debug map-get($colors); //terminal prints ─> sass:map 1 │ @function get($map, $key, $keys...) { // Test a color with @debug map-get($colors, "purple"); // terminal prints: DEBUG: #9900ff // evaluation to true or false @debug map-has-key($colors, "firebrick"); //DEBUG: false
@extends('new_layouts.app') @section('styles') <style> .custom-table { border-collapse: collapse; border-radius: 1rem; border-style: hidden; box-shadow: 0 0 0 1px #e6ebef; overflow: hidden; text-align: left; width: 100%; } .badge-file-extension { background-color: #f25961; color: white; padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: 0.375rem; margin-left: 0.5rem; } .bookmark-active svg { fill: #FF9800; } .description-text { font-size: 1.1rem; color: #555; margin-top: 0.5rem; } .comment { margin-top: 1rem; margin-bottom: 1rem; } .comment-section { border: 1px solid #e9ebee; border-radius: 1rem; padding: 1.5rem; background-color: #ffffff; /* box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1); */ } .comment-header { border-bottom: 1px solid #e9ebee; padding-bottom: 0.75rem; margin-bottom: 1rem; } .comment-avatar { height: 48px; width: 48px; border-radius: 50%; margin-right: 1rem; } .comment-author { font-size: 1rem; font-weight: 600; } .comment-time { font-size: 0.875rem; color: #90949c; } .comment-body { margin: 0.75rem 0; font-size: 1rem; } .comment-actions a { font-size: 0.875rem; color: #4267b2; text-decoration: none; margin-right: 1rem; } .comment-actions i { margin-right: 0.5rem; } .reply-list { margin-top: 1rem; padding-left: 2rem; } .reply-list .comment { border-left: 1px dotted #d3d6db; padding-left: 1rem; margin-top: 1rem; } .reply-toggle { cursor: pointer; font-size: 0.875rem; color: #4267b2; text-decoration: none; margin-top: 1rem; display: block; } .reply-form { display: none; position: relative; z-index: 10; } .comment-input { border-radius: 0.5rem; } .like-button.active i { color: #4caf50; } .dislike-button.active i { color: #dc3545; } /* Dropdown Styles */ .dropdown-toggle::after { display: none; /* Remove the default arrow */ } .dropdown-menu { right: 0; left: auto; } </style> @endsection @section('content') <div> <div class="d-flex flex-column"> <h1>Title: {{ $material->title }}</h1> @if ($material->description) <p class="description-text"><strong>Description:</strong> {{ $material->description }}</p> @endif </div> <div class="d-flex justify-content-end mb-4"> <a class="btn rounded-3" style="background-color: #4CAF50; color: white" href="{{ route('materials.downloadAll', $material) }}"> <i class="fas fa-download me-1"></i> Download All </a> </div> <div class="table-responsive"> <table class="table table-striped custom-table"> <thead> <tr> <th scope="col">Bookmarks</th> <th scope="col">Document</th> <th scope="col">Action</th> </tr> </thead> <tbody> @foreach ($files as $file) <tr> <td> @php $isBookmarked = $file->bookmarks()->where('user_id', Auth::id())->exists(); @endphp <button type="button" class="btn btn-outline-dark bookmark-toggle {{ $isBookmarked ? 'bookmark-active' : '' }}" data-file-id="{{ $file->id }}"> @if ($isBookmarked) <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z" /> <path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z" /> </svg> @else <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z" /> <path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1" /> </svg> @endif <span class="visually-hidden">Button</span> </button> </td> <td> <div> @php $extension = pathinfo($file->name, PATHINFO_EXTENSION); @endphp <i class="fa-solid fa-file-lines" style="color: #0068b8; margin-right: 5px;"></i> <a href="{{ Storage::url($file->path) }}" target="_blank"> {{ pathinfo($file->name, PATHINFO_FILENAME) }} </a> <span> <span class="badge badge-file-extension"> {{ strtoupper($extension) }} File </span> </span> </div> </td> <td> <a class="btn btn-primary rounded-pill" href="{{ route('files.download', $file) }}"> <i class="fas fa-download me-1"></i> Download </a> </td> </tr> @endforeach </tbody> </table> </div> </div> <div class="container"> <div class="mt-4 comment-section"> <h3>Comments ( {{ $comments->count() }} )</h3> <div class="comment-header d-flex justify-content-between align-items-center"> </div> <div class="comment-body"> <div class="d-flex mb-3"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <form id="comment-form" action="{{ route('comments.store', $material) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a comment..." rows="3"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger"></div> <button type="submit" class="btn btn-primary">Post Comment</button> </div> </div> </form> </div> </div> <div id="comment-list" class="comment-list"> @foreach ($comments as $comment) <div class="comment" data-comment-id="{{ $comment->id }}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">{{ $comment->user->name }}</div> <div class="comment-time">{{ $comment->created_at->diffForHumans() }}</div> </div> @if ($comment->user_id === auth()->id()) <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton{{ $comment->id }}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton{{ $comment->id }}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="{{ $comment->id }}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="{{ $comment->id }}">Delete</a></li> </ul> </div> @endif </div> <div class="comment-body">{{ $comment->content }}</div> <div class="comment-actions"> <a href="#" class="like-button {{ $comment->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="like" data-comment-id="{{ $comment->id }}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">{{ $comment->likes }}</span> </a> <a href="#" class="dislike-button {{ $comment->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="dislike" data-comment-id="{{ $comment->id }}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">{{ $comment->dislikes }}</span> </a> <a href="#" class="reply-link" data-comment-id="{{ $comment->id }}" data-author="{{ $comment->user->name }}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <div class="reply-toggle" onclick="toggleReplies(this)">View replies</div> <form class="reply-form" action="{{ route('replies.store', $comment) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"> @foreach ($comment->replies as $reply) <div class="comment reply" data-comment-id="{{ $reply->id }}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">{{ $reply->user->name }}</div> <div class="comment-time"> {{ $reply->created_at->diffForHumans() }}</div> </div> @if ($reply->user_id === auth()->id()) <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton{{ $reply->id }}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton{{ $reply->id }}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="{{ $reply->id }}">Edit</a> </li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="{{ $reply->id }}">Delete</a> </li> </ul> </div> @endif </div> <div class="comment-body"> @if ($reply->parent) <a href="#" class="reply-mention">{{ '@' . $reply->parent->user->name }}</a> @endif <span class="reply-content">{{ $reply->content }}</span> </div> <div class="comment-actions"> <a href="#" class="like-button {{ $reply->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="like" data-comment-id="{{ $reply->id }}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">{{ $reply->likes }}</span> </a> <a href="#" class="dislike-button {{ $reply->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}" data-action="dislike" data-comment-id="{{ $reply->id }}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">{{ $reply->dislikes }}</span> </a> <a href="#" class="reply-link" data-comment-id="{{ $reply->id }}" data-author="{{ $reply->user->name }}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <form class="reply-form" action="{{ route('replies.store', $reply) }}" method="POST"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> </div> </div> </div> @include('materials.comment', ['replies' => $reply->replies]) @endforeach </div> </div> </div> </div> @endforeach </div> </div> </div> </div> <!-- Modal for delete confirmation --> <div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-body text-center"> <div class="mb-3"> <i class="fa-solid fa-triangle-exclamation modal-icon"></i> </div> <h5 class="modal-title" id="deleteModalLabel">Delete Comment</h5> <p>Are you sure you want to delete this comment?</p> </div> <div class="modal-footer d-flex justify-content-center"> <button type="button" class="btn btn-danger ms-2" id="confirmDelete">Delete</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> </div> </div> </div> </div> @endsection @section('scripts') <script> document.addEventListener('DOMContentLoaded', function() { const commentList = document.getElementById('comment-list'); // Handle edit button click commentList.addEventListener('click', function(event) { const button = event.target.closest('a[data-action="edit"]'); if (button) { event.preventDefault(); const commentId = button.getAttribute('data-comment-id'); const commentElement = document.querySelector( `.comment[data-comment-id="${commentId}"]`); const commentBodyElement = commentElement.querySelector('.comment-body'); // Extract mention and content const mentionElement = commentBodyElement.querySelector('.reply-mention'); const mention = mentionElement ? mentionElement.innerText.trim() : ''; const contentElement = mentionElement ? mentionElement.nextElementSibling : commentBodyElement; const content = contentElement.innerText.trim(); // Store original content for cancel action commentBodyElement.dataset.originalContent = commentBodyElement.innerHTML; const editForm = ` <form class="edit-comment-form" data-comment-id="${commentId}"> ${mention ? `<span class="reply-mention">${mention}</span>` : ''} <textarea class="form-control">${content}</textarea> <button type="submit" class="btn btn-primary mt-2">Save</button> <button type="button" class="btn btn-secondary mt-2 cancel-edit">Cancel</button> </form> `; commentBodyElement.innerHTML = editForm; attachEditFormListeners(commentId); } }); function attachEditFormListeners(commentId) { const editForm = document.querySelector(`.edit-comment-form[data-comment-id="${commentId}"]`); editForm.addEventListener('submit', function(e) { e.preventDefault(); const textarea = this.querySelector('textarea'); const content = textarea.value; const mention = this.querySelector('.reply-mention') ? this.querySelector( '.reply-mention').innerText.trim() : ''; fetch(`/comments/${commentId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content') }, body: JSON.stringify({ content }) }) .then(response => response.json()) .then(data => { if (data.success) { const commentBodyElement = document.querySelector( `.comment[data-comment-id="${commentId}"] .comment-body`); const mentionElement = mention ? `<a href="#" class="reply-mention">${mention}</a>` : ''; commentBodyElement.innerHTML = `${mentionElement} <span class="reply-content">${data.content}</span>`; } else { alert('Error updating comment.'); } }) .catch(error => { console.error('Error:', error); }); }); editForm.querySelector('.cancel-edit').addEventListener('click', function() { const originalContent = document.querySelector( `.comment[data-comment-id="${commentId}"] .comment-body`).dataset .originalContent; document.querySelector(`.comment[data-comment-id="${commentId}"] .comment-body`) .innerHTML = originalContent; }); } }); </script> <script> document.addEventListener('DOMContentLoaded', function() { // for delete let commentIdToDelete = null; document.getElementById('comment-list').addEventListener('click', function(event) { const button = event.target.closest('a[data-action="delete"]'); if (button) { event.preventDefault(); commentIdToDelete = button.getAttribute('data-comment-id'); // Show the delete confirmation modal const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal')); deleteModal.show(); } }); document.getElementById('confirmDelete').addEventListener('click', function() { if (commentIdToDelete) { fetch(`/comments/${commentIdToDelete}`, { method: 'DELETE', headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content'), 'Content-Type': 'application/json', } }) .then(response => response.json()) .then(data => { if (data.success) { const commentElement = document.querySelector( `.comment[data-comment-id="${commentIdToDelete}"]`); if (commentElement) { commentElement.remove(); } } else { alert('Error: Comment deleted because parent removed'); } }) .catch(error => { // console.error('Error:', error); // alert('Something went wrong'); }); const deleteModal = bootstrap.Modal.getInstance(document.getElementById('deleteModal')); deleteModal.hide(); } }); // for like and dislike document.getElementById('comment-list').addEventListener('click', function(event) { const button = event.target.closest('a'); if (button && (button.classList.contains('like-button') || button.classList.contains( 'dislike-button'))) { event.preventDefault(); const commentId = button.getAttribute('data-comment-id'); const action = button.getAttribute('data-action'); fetch(`/comments/${commentId}/${action}`, { method: 'POST', headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content'), 'Content-Type': 'application/json', }, body: JSON.stringify({ _method: 'POST' }) }) .then(response => response.json()) .then(data => { if (data.success) { const commentElement = document.querySelector( `.comment[data-comment-id="${commentId}"]`); const likeCount = commentElement.querySelector( '.like-button .like-dislike-count'); const dislikeCount = commentElement.querySelector( '.dislike-button .like-dislike-count'); likeCount.textContent = data.comment.likes; dislikeCount.textContent = data.comment.dislikes; if (action === 'like') { button.classList.toggle('active'); commentElement.querySelector('.dislike-button').classList.remove( 'active'); } else { button.classList.toggle('active'); commentElement.querySelector('.like-button').classList.remove( 'active'); } } else { alert(data.message || 'Error updating like/dislike'); } }) .catch(error => { console.error('Error:', error); alert('Something went wrong'); }); } }); // For submission of the main comment form document.getElementById('comment-form')?.addEventListener('submit', function(event) { event.preventDefault(); const formData = new FormData(this); const errorDiv = document.getElementById('comment-form-error'); errorDiv.textContent = ''; // Clear previous errors fetch(this.action, { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content') } }) .then(response => response.json()) .then(data => { if (data.success) { const commentList = document.getElementById('comment-list'); if (commentList) { const newCommentHtml = ` <div class="comment" data-comment-id="${data.comment.id}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">${data.comment.user_name}</div> <div class="comment-time">${data.comment.created_at}</div> </div> <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.comment.id}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.comment.id}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.comment.id}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.comment.id}">Delete</a></li> </ul> </div> </div> <div class="comment-body">${data.comment.content}</div> <div class="comment-actions"> <a href="#" class="like-button" data-action="like" data-comment-id="${data.comment.id}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.comment.id}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="reply-link" data-comment-id="${data.comment.id}" data-author="${data.comment.user_name}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <div class="reply-toggle" onclick="toggleReplies(this)">View replies</div> <form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"></div> </div> </div> </div> `.replace(':commentId', data.comment.id); commentList.insertAdjacentHTML('afterbegin', newCommentHtml); this.reset(); initializeDropdowns(); } } else { // Display error messages errorDiv.textContent = data.error || 'Your comment is empty'; } }) .catch(error => { console.error('Error:', error); errorDiv.textContent = 'Something went wrong'; }); }); // For submission of reply forms document.getElementById('comment-list')?.addEventListener('submit', function(event) { if (event.target.closest('.reply-form')) { event.preventDefault(); const form = event.target; const formData = new FormData(form); const parentId = form.closest('.comment').dataset.commentId; const errorDiv = form.querySelector('#comment-form-error'); // Reset error display errorDiv.style.display = 'none'; errorDiv.textContent = ''; fetch(form.action.replace(':commentId', parentId), { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]') .getAttribute('content') } }) .then(response => response.json()) .then(data => { if (data.success) { const replyList = form.closest('.reply-list') || form.closest( '.comment').querySelector('.reply-list'); if (replyList) { const newReplyHtml = ` <div class="comment reply" data-comment-id="${data.reply.id}"> <div class="d-flex"> <img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar"> <div class="w-100"> <div class="d-flex justify-content-between align-items-start"> <div> <div class="comment-author">${data.reply.user_name}</div> <div class="comment-time">${data.reply.created_at}</div> </div> <div class="dropdown"> <button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.reply.id}" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa-solid fa-ellipsis-vertical"></i> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.reply.id}"> <li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.reply.id}">Edit</a></li> <li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.reply.id}">Delete</a></li> </ul> </div> </div> <div class="comment-body"> ${data.reply.parent_name ? `<a href="#" class="reply-mention">@${data.reply.parent_name}</a> ` : ''} <span class="reply-content">${data.reply.content}</span> </div> <div class="comment-actions"> <a href="#" class="like-button" data-action="like" data-comment-id="${data.reply.id}"> <i class="fa-solid fa-thumbs-up"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.reply.id}"> <i class="fa-solid fa-thumbs-down"></i> <span class="like-dislike-count">0</span> </a> <a href="#" class="reply-link" data-comment-id="${data.reply.id}" data-author="${data.reply.user_name}"> <i class="fa-solid fa-reply"></i> Reply </a> </div> <form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;"> @csrf <div class="d-flex flex-column"> <textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea> <div class="d-flex justify-content-between mt-2"> <div id="comment-form-error" class="text-danger" style="display: none;"> Error: Reply cannot be empty </div> <button type="submit" class="btn btn-primary ms-auto">Post Reply</button> </div> </div> </form> <div class="reply-list" style="display: none;"></div> </div> </div> </div> `.replace(':commentId', data.reply.id); replyList.insertAdjacentHTML('beforeend', newReplyHtml); form.reset(); form.style.display = 'none'; // Hide the reply form after successful submission // Ensure the replies are displayed const replyToggle = form.closest('.comment').querySelector( '.reply-toggle'); if (replyToggle) { const replyList = replyToggle.nextElementSibling .nextElementSibling; replyList.style.display = 'block'; replyToggle.textContent = 'Hide replies'; } initializeDropdowns(); } } else { // Display error message errorDiv.textContent = data.message || 'Error posting reply'; errorDiv.style.display = 'block'; } }) .catch(error => { console.error('Error:', error); // Display error message errorDiv.textContent = 'Something went wrong'; errorDiv.style.display = 'block'; }); } }); // For reply link click to show reply form document.getElementById('comment-list')?.addEventListener('click', function(event) { if (event.target.closest('.reply-link')) { event.preventDefault(); const replyForm = event.target.closest('.comment').querySelector('.reply-form'); if (replyForm) { replyForm.style.display = replyForm.style.display === 'block' ? 'none' : 'block'; } } }); }); function initializeDropdowns() { const dropdowns = document.querySelectorAll('.dropdown-toggle:not(.initialized)'); dropdowns.forEach(dropdown => { new bootstrap.Dropdown(dropdown); dropdown.classList.add('initialized'); }); } function toggleReplies(element) { const replyList = element.nextElementSibling.nextElementSibling; const isVisible = replyList.style.display === 'block'; replyList.style.display = isVisible ? 'none' : 'block'; element.textContent = isVisible ? 'View replies' : 'Hide replies'; } </script> <script> document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.bookmark-toggle').forEach(function(button) { button.addEventListener('click', function() { const fileId = this.getAttribute('data-file-id'); const button = this; fetch("{{ route('bookmark.toggle') }}", { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, body: JSON.stringify({ file_id: fileId }) }) .then(response => response.json()) .then(data => { if (data.status === 'added') { button.classList.add('bookmark-active'); button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z"/> <path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z"/> </svg>`; } else if (data.status === 'removed') { button.classList.remove('bookmark-active'); button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16"> <path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z"/> <path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1"/> </svg>`; } }) .catch(error => console.error('Error:', error)); }); }); }); </script> @endsection
def uploadData(sheet, email, sheet_name): if sheet_name == "2.BaseData": data = [] headers = [cell.value for cell in sheet[1]] for row in sheet.iter_rows(min_row=2): row_data = { headers[i]: cell.value for i, cell in enumerate(row) if cell.value is not None } if row_data: # Only append if row_data is not empty row_data = trim_dict_spaces(row_data) data.append(row_data) print(data) # If socio_econ_vulnerability_collection expects each row to be uploaded individually for row in data: socio_econ_vulnerability_collection.add(row) return data
//////////////////SIMPLE///////////// function create_posttype() { register_post_type( 'movies', // CPT Options array( 'labels' => array( 'name' => __( 'Movies' ), 'singular_name' => __( 'Movie' ) ), 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'movies'), 'show_in_rest' => true, ) ); } // Hooking up our function to theme setup add_action( 'init', 'create_posttype' ); /////////////////////////Complex Custom///////////////////////// /* * Creating a function to create our CPT */ function custom_post_type() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'Movies', 'Post Type General Name', 'twentytwentyone' ), 'singular_name' => _x( 'Movie', 'Post Type Singular Name', 'twentytwentyone' ), 'menu_name' => __( 'Movies', 'twentytwentyone' ), 'parent_item_colon' => __( 'Parent Movie', 'twentytwentyone' ), 'all_items' => __( 'All Movies', 'twentytwentyone' ), 'view_item' => __( 'View Movie', 'twentytwentyone' ), 'add_new_item' => __( 'Add New Movie', 'twentytwentyone' ), 'add_new' => __( 'Add New', 'twentytwentyone' ), 'edit_item' => __( 'Edit Movie', 'twentytwentyone' ), 'update_item' => __( 'Update Movie', 'twentytwentyone' ), 'search_items' => __( 'Search Movie', 'twentytwentyone' ), 'not_found' => __( 'Not Found', 'twentytwentyone' ), 'not_found_in_trash' => __( 'Not found in Trash', 'twentytwentyone' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'movies', 'twentytwentyone' ), 'description' => __( 'Movie news and reviews', 'twentytwentyone' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array( 'genres' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', 'show_in_rest' => true, ); // Registering your Custom Post Type register_post_type( 'movies', $args ); } /* Hook into the 'init' action so that the function * Containing our post type registration is not * unnecessarily executed. */ add_action( 'init', 'custom_post_type', 0 );
1. Find the product id and unit list price of products belonging to the 'Yoghurt' category. SELECT product_id, unit_list_price FROM products WHERE product_category = 'yoghurt'; ----------- 2. Find all the information (i.e., all columns) of the managers with null values in their first name. SELECT * FROM managers WHERE first_name IS NULL; ----------- 3. Find the sales ID and sales date where quantity sold on that date is greater than or equal to 2100. SELECT sales_id, sales_date, quantity_sold FROM sales WHERE quantity_sold >= 2100; ----------- 4. Find the manager ID and the sum of quantity sold for all products (except those with ID 7001001) for each of the managers in the sales table and sort the output by manager ID in descending order. SELECT sales_manager_id, SUM(quantity_sold) AS quant_sold FROM sales WHERE product_id <> 7001001 GROUP BY sales_manager_id ORDER BY sales_manager_id DESC; ----------- 5. Find the product ID, product name, and unit production cost of the products with maximum unit production cost below $1.10 and sort the output by production cost in ascending order (HINT: Use HAVING). SELECT product_id, product_name, MAX(unit_production_cost) AS unit_production_cost FROM products GROUP BY 1 , 2 HAVING MAX(unit_production_cost) < 1.10 ORDER BY unit_production_cost DESC; SELECT product_id, product_name, unit_production_cost FROM products WHERE unit_production_cost < 1.10 ORDER BY unit_production_cost DESC; ----------- 6. Find the product ID and sales date with the highest quantity sold from sales transacted after 30 Oct 2021 (exclusive) except for products with IDs 7001001 and 7001002. SELECT product_id, sales_date, quantity_sold FROM sales WHERE sales_date > '2021-10-30' AND product_id NOT IN (7001001 , 7001002) ORDER BY quantity_sold desc LIMIT 1; SELECT product_id, sales_date, quantity_sold FROM sales WHERE sales_date > '2021-10-30';
'Find the listNum of a Custom List based on all items Dim listNumFound As Integer listNumFound = Application.GetCustomListNum(Array("Element1", "Element2", "Element3")) 'Find a Custom List which contains a specific element Dim i As Integer Dim arrayItem As Variant Dim customListContents() As Variant Dim listNumFound As Integer For i = 1 To Application.CustomListCount 'Set the CustomList array to a variable customListContents = Application.GetCustomListContents(i) 'Loop through each element in the CustomList For Each arrayItem In customListContents 'Test if the element has a specific value If arrayItem = "Element1" Then listNumFound=i Next arrayItem Next i
'Add a new Custom List Application.AddCustomList ListArray:=Array("Element1", "Element2", "Element3") 'Add a new Custom List from range of cells Application.AddCustomList ListArray:=Range("Sheet1!A1:A3")
#include <iostream> #include <vector> #include <queue> #include <utility> // cho std::pair using namespace std; void D(int N, vector<vector<pair<int, int>>> &adj, int source) { vector<int> dist(N, 1000000); // Khởi tạo khoảng cách đến tất cả các đỉnh là vô cùng dist[source] = 0; // Khoảng cách từ đỉnh nguồn đến chính nó là 0 // Hàng đợi ưu tiên với hàm so sánh priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int> > > pq; pq.push(make_pair(0, source)); while (!pq.empty()) { // Trong khi hàng đợi không rỗng int u = pq.top().second; // Lấy đỉnh có khoảng cách nhỏ nhất int d = pq.top().first; // Khoảng cách từ nguồn đến đỉnh u pq.pop(); // Duyệt các đỉnh kề của đỉnh u for (int i = 0; i < adj[u].size(); i++) { int v = adj[u][i].first; // Đỉnh kề int weight = adj[u][i].second; // Trọng số của cạnh // Nếu tìm được đường đi ngắn hơn đến đỉnh v if (dist[v] > dist[u] + weight) { dist[v] = dist[u] + weight; pq.push(make_pair(dist[v], v)); // Đẩy khoảng cách mới vào hàng đợi } } } // In ra kết quả khoảng cách từ đỉnh nguồn đến tất cả các đỉnh khác for (int i = 0; i < N; i++) { cout << "Khoảng cách từ " << source << " đến " << i << " là " << dist[i] << endl; } } int main() { int N, M; // Số đỉnh, số cạnh cin >> N >> M; vector<vector<pair<int, int> > > adj(N); // Mảng vector để lưu đồ thị for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; adj[a].push_back(make_pair(b, c)); // Đồ thị có hướng adj[b].push_back(make_pair(a, c)); // Nếu đồ thị là vô hướng } int source; cin >> source; D(N, adj, source); return 0; }
import pandas as pd import ta # For technical indicators import tensorflow as tf from stable_baselines3 import PPO # Deep Reinforcement Learning Model import asyncio # For asynchronous operations import aiohttp # For asynchronous HTTP requests from transformers import pipeline # Huggingface for news sentiment from datetime import datetime, timedelta import numpy as np from sklearn.preprocessing import MinMaxScaler import gym import MetaTrader5 as mt5 # Assuming MetaTrader5 is imported # Replace with your login details account = 165142091 # Your account number password = "pec100demo@xm" server = "XMGlobal-MT5 2" # Initialize MT5 connection if not mt5.initialize(login=account, password=password, server=server): print("Failed to initialize MT5, error:", mt5.last_error()) quit() else: print("Logged in successfully!") account_info = mt5.account_info() if account_info is None: print("Failed to get account info, error:", mt5.last_error()) else: print(account_info) # Async function to fetch OHLC data for a symbol async def fetch_data(symbol, timeframe, count=1000): loop = asyncio.get_event_loop() rates = await loop.run_in_executor(None, lambda: mt5.copy_rates_from_pos(symbol, timeframe, 0, count)) data = pd.DataFrame(rates) data['time'] = pd.to_datetime(data['time'], unit='s') data.set_index('time', inplace=True) # Calculate technical indicators data['EMA_50'] = ta.trend.ema_indicator(data['close'], window=50) data['SMA_100'] = ta.trend.sma_indicator(data['close'], window=100) data['RSI'] = ta.momentum.rsi(data['close'], window=14) data['MACD'] = ta.trend.macd(data['close']) data['SuperTrend'] = ta.volatility.AverageTrueRange(high=data['high'], low=data['low'], close=data['close']).average_true_range() data['AwesomeOscillator'] = ta.momentum.awesome_oscillator(data['high'], data['low']) return data # Async function to fetch news async def fetch_news(symbol): api_url = f"https://newsapi.org/v2/everything?q={symbol}&apiKey=YOUR_API_KEY" async with aiohttp.ClientSession() as session: async with session.get(api_url) as response: news_data = await response.json() return news_data['articles'] # Analyze the sentiment of news def analyze_news(articles): sentiment_pipeline = pipeline('sentiment-analysis') sentiment_scores = [] for article in articles: sentiment = sentiment_pipeline(article['description'])[0] sentiment_scores.append(sentiment['score'] if sentiment['label'] == 'POSITIVE' else -sentiment['score']) return np.mean(sentiment_scores) # Asynchronously process news for multiple assets async def process_news_for_assets(symbols): news_sentiments = {} for symbol in symbols: articles = await fetch_news(symbol) news_sentiments[symbol] = analyze_news(articles) return news_sentiments # Fetch and process data for multiple assets asynchronously async def fetch_all_data(symbols, timeframe): tasks = [fetch_data(symbol, timeframe) for symbol in symbols] results = await asyncio.gather(*tasks) return dict(zip(symbols, results)) # Class representing the trading environment for Reinforcement Learning class TradingEnv(gym.Env): def __init__(self, data, news_sentiment, target_profit, time_limit): super(TradingEnv, self).__init__() self.data = data self.news_sentiment = news_sentiment # News sentiment incorporated into the state self.current_step = 0 self.initial_balance = 10000 self.balance = self.initial_balance self.positions = [] self.done = False self.target_profit = target_profit # Desired profit to achieve self.start_time = datetime.now() self.time_limit = timedelta(minutes=time_limit) # Time frame to reach the target profit # Define action and observation space self.action_space = gym.spaces.Discrete(3) # 0 = Hold, 1 = Buy, 2 = Sell self.observation_space = gym.spaces.Box(low=-1, high=1, shape=(len(self.data.columns) + 1,), dtype=np.float16) def reset(self): self.balance = self.initial_balance self.positions = [] self.current_step = 0 self.start_time = datetime.now() return self._next_observation() def _next_observation(self): obs = self.data.iloc[self.current_step].values obs = np.append(obs, self.news_sentiment) # Add sentiment as part of the observation scaler = MinMaxScaler() obs = scaler.fit_transform([obs])[0] return obs def step(self, action): reward = 0 self.current_step += 1 current_price = self.data['close'].iloc[self.current_step] if action == 1: # Buy self.positions.append(current_price) elif action == 2: # Sell if len(self.positions) > 0: bought_price = self.positions.pop(0) profit = current_price - bought_price reward += profit self.balance += profit # Add trailing stop-loss and take-profit logic here # Example: Adjust TP based on current price trailing_distance = 50 if len(self.positions) > 0: bought_price = self.positions[0] new_tp = current_price - trailing_distance * 0.0001 if new_tp > bought_price + trailing_distance * 0.0001: # Adjust TP logic pass # Check if target profit or time limit is reached if self.balance - self.initial_balance >= self.target_profit: self.done = True print(f"Target profit reached: {self.balance - self.initial_balance}") elif datetime.now() - self.start_time > self.time_limit: self.done = True print(f"Time limit reached: Balance = {self.balance}") return self._next_observation(), reward, self.done, {} # Initialize environment and PPO model async def main(): symbols = ['EURUSD', 'BTCUSD'] timeframe = mt5.TIMEFRAME_H1 target_profit = 500 # User-defined target profit time_limit = 60 # Time limit in minutes # Fetch data and news asynchronously asset_data = await fetch_all_data(symbols, timeframe) news_sentiment = await process_news_for_assets(symbols) # Initialize trading environment env = TradingEnv(asset_data['EURUSD'], news_sentiment['EURUSD'], target_profit, time_limit) # Initialize PPO model model = PPO('MlpPolicy', env, verbose=1) model.learn(total_timesteps=10000) # Run the async main function asyncio.run(main())
--- __Advertisement :)__ - __[pica](https://nodeca.github.io/pica/demo/)__ - high quality and fast image resize in browser. - __[babelfish](https://github.com/nodeca/babelfish/)__ - developer friendly i18n with plurals support and easy syntax. You will like those projects! --- # h1 Heading 8-) ## h2 Heading ### h3 Heading #### h4 Heading ##### h5 Heading ###### h6 Heading ## Horizontal Rules ___ --- *** ## Typographic replacements Enable typographer option to see result. (c) (C) (r) (R) (tm) (TM) (p) (P) +- test.. test... test..... test?..... test!.... !!!!!! ???? ,, -- --- "Smartypants, double quotes" and 'single quotes' ## Emphasis **This is bold text** __This is bold text__ *This is italic text* _This is italic text_ ~~Strikethrough~~ ## Blockquotes > Blockquotes can also be nested... >> ...by using additional greater-than signs right next to each other... > > > ...or with spaces between arrows. ## Lists Unordered + Create a list by starting a line with `+`, `-`, or `*` + Sub-lists are made by indenting 2 spaces: - Marker character change forces new list start: * Ac tristique libero volutpat at + Facilisis in pretium nisl aliquet - Nulla volutpat aliquam velit + Very easy! Ordered 1. Lorem ipsum dolor sit amet 2. Consectetur adipiscing elit 3. Integer molestie lorem at massa 1. You can use sequential numbers... 1. ...or keep all the numbers as `1.` Start numbering with offset: 57. foo 1. bar ## Code Inline `code` Indented code // Some comments line 1 of code line 2 of code line 3 of code Block code "fences" ``` Sample text here... ``` Syntax highlighting ``` js var foo = function (bar) { return bar++; }; console.log(foo(5)); ``` ## Tables | Option | Description | | ------ | ----------- | | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. | Right aligned columns | Option | Description | | ------:| -----------:| | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. | ## Links [link text](http://dev.nodeca.com) [link with title](http://nodeca.github.io/pica/demo/ "title text!") Autoconverted link https://github.com/nodeca/pica (enable linkify to see) ## Images   Like links, Images also have a footnote style syntax ![Alt text][id] With a reference later in the document defining the URL location: [id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat" ## Plugins The killer feature of `markdown-it` is very effective support of [syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin). ### [Emojies](https://github.com/markdown-it/markdown-it-emoji) > Classic markup: :wink: :cry: :laughing: :yum: > > Shortcuts (emoticons): :-) :-( 8-) ;) see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji. ### [Subscript](https://github.com/markdown-it/markdown-it-sub) / [Superscript](https://github.com/markdown-it/markdown-it-sup) - 19^th^ - H~2~O ### [\<ins>](https://github.com/markdown-it/markdown-it-ins) ++Inserted text++ ### [\<mark>](https://github.com/markdown-it/markdown-it-mark) ==Marked text== ### [Footnotes](https://github.com/markdown-it/markdown-it-footnote) Footnote 1 link[^first]. Footnote 2 link[^second]. Inline footnote^[Text of inline footnote] definition. Duplicated footnote reference[^second]. [^first]: Footnote **can have markup** and multiple paragraphs. [^second]: Footnote text. ### [Definition lists](https://github.com/markdown-it/markdown-it-deflist) Term 1 : Definition 1 with lazy continuation. Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2. _Compact style:_ Term 1 ~ Definition 1 Term 2 ~ Definition 2a ~ Definition 2b ### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr) This is HTML abbreviation example. It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on. *[HTML]: Hyper Text Markup Language ### [Custom containers](https://github.com/markdown-it/markdown-it-container) ::: warning *here be dragons* :::
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="1st-style.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <title>Portfolio</title> </head> <body> <nav> <h1><span><i class="fa-solid fa-user-tie"></i> Potfolio:)</span></h1> <ul> <li><a><i class="fa-solid fa-house"></i> HOME</a></li> <li><a> <i class="fa-solid fa-eject"></i> ABOUT</a></li> <li><a><i class="fa-brands fa-servicestack"></i> SERVICES</a></li> <li><a><i class="fa-solid fa-phone"></i> CONTACT</a></li> <button>HIRE ME</button> </ul> </nav> <div class="container"> <div class="text"> <h2>I'm TAHA SOHAIL :)</h2> <h1>I'm WEB DEVELOPER!</h1> <p>This is my Personal Portfolio Website, Where you find my work, <br> Experiance and More...</p> <button><i class="fa-solid fa-download"></i> Download CV</button> </div> <div class="img"> <img src="https://i.ibb.co/Mf4B314/taha-1.png" alt=""> </div> </div> </body> </html> CSS_______________________________________________________________________________________CSS * { margin: 0; padding: 0; } body { background-color: #464646; color: white; } nav { box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; background-color: gray; padding: 30px; display: flex; justify-content: center; justify-content: space-around; } nav h1 { color: rgb(241, 42, 7); font-size: 30px; } nav h1:hover { color: black; } ul { display: flex; list-style: none; } ul li a { margin-inline: 27px; font-size: 20px; } ul li a:hover { font-size: 22px; color: black; } ul button { font-size: 20px; background-color: rgb(243, 45, 10); color: wheat; height: 35px; width: 120px; border: none; cursor: pointer; } ul button:hover { background-color: black; font-size: 25px; border: 2px solid white; } .container { display: flex; justify-content: space-around; margin-top: 50px; } .text { margin-top: 40px; } .text h2 { color: black; font-size: 30px; } .text h1 { color: rgb(247, 41, 5); font-size: 40px; } .text button { margin-top: 20px; font-size: 20px; background-color: rgb(243, 48, 13); color: white; height: 50px; width: 160px; border: none; cursor: pointer; } .text button:hover { background-color: black; font-size: 25px; border: 2px solid white; } .img { box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; }
powershell -C "irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 ^| iex"
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Multiple Split Text Animations</title> <style> .ys-cool-split { width: 85%; font-size: 2rem; color: rgba(255, 255, 255, 0.125); transition: color 0.3s; margin: 50vh 0; /* Added margin to simulate scrolling */ } body { margin: 0; background-color: #111; } </style> </head> <body> <h2 class="ys-cool-split">First Split Text Animation</h2> <h2 class="ys-cool-split">Second Split Text Animation</h2> <h2 class="ys-cool-split">Third Split Text Animation</h2> <!-- Place your JS scripts here, at the end of the body --> <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script> <script src="https://unpkg.com/gsap@3/dist/ScrollTrigger.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/split-type@0.3.4/umd/index.min.js"></script> <script> gsap.registerPlugin(ScrollTrigger); document.querySelectorAll('.ys-cool-split').forEach(element => { const split = new SplitType(element, { types: 'words, chars' }); const tl = gsap.timeline({ scrollTrigger: { trigger: element, start: 'top 85%', end: 'top 15%', scrub: 0.5, }, }); tl.set(split.chars, { duration: 0.3, color: 'white', stagger: 0.1, }, 0.1); }); </script> </body> </html>
If you want to develop a payment app for your business, most people choose one payment app solution, which is a Cash app clone. Because it has come with a lot of merits for their business, entrepreneurs believe in this app. According to their mindset of developing a peer-to-peer payment app with the combination of user profiles, stock trading, bitcoin buying, or debit card integration, and in-app messaging. These features considered to build your dreamier p2p payment app, like a cash app, are expensive and will take around $10,000 to more than $60,000 because it depends upon choosing your platform technology, and complexity level. If you're looking to develop your cash payment app clone for your business, then Appticz is the prominent solution for all your needs.
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:ghalam_jadoee/pages/Addpage.dart'; import 'package:lottie/lottie.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; import 'package:url_launcher/url_launcher.dart'; final Uri _url = Uri.parse('https://t.me/ir_samstudio'); final Uri _url2 = Uri.parse('info@samstudio.app'); void main() { runApp(const MaterialApp( home: About(), )); } class About extends StatefulWidget { const About({super.key}); @override State<About> createState() => _AboutState(); } TutorialCoachMark? tutorialCoachMark; List<TargetFocus> targets = []; GlobalKey Samkey = GlobalKey(); GlobalKey telkey = GlobalKey(); GlobalKey bazarkey = GlobalKey(); @override void initState() {} bool DarkMod = false; class _AboutState extends State<About> { @override void initState() { super.initState(); Future.delayed(const Duration(seconds: 1), () { _showtutorialCoachmark(); }); } void _showtutorialCoachmark() { _initTaget(); tutorialCoachMark = TutorialCoachMark( targets: targets, pulseEnable: false, colorShadow: Colors.black, hideSkip: true) ..show(context: context); } void _initTaget() { targets.addAll([ TargetFocus( identify: "Sam", keyTarget: Samkey, shape: ShapeLightFocus.RRect, contents: [ TargetContent( align: ContentAlign.top, builder: (context, controller) { return CoachmarkDesc( text: "نام تجاری شرکت که با الگو از مختصر اسامی اصلی اعضا تیم است", onNext: () { controller.next(); }, onSkip: () { controller.skip(); }, ); }, ), ], ), TargetFocus( identify: "tel_key", keyTarget: telkey, contents: [ TargetContent( align: ContentAlign.bottom, builder: (context, controller) { return CoachmarkDesc( text: "شما میتوانید با عضو شدن در شبگه های اجتماعی از اخرین تغییرات خبردار شوید", onNext: () { controller.next(); }, onSkip: () { controller.skip(); }, ); }, ), ], ), TargetFocus( identify: "bazar_key", keyTarget: bazarkey, shape: ShapeLightFocus.RRect, contents: [ TargetContent( align: ContentAlign.bottom, builder: (context, controller) { return CoachmarkDesc( text: "با ثبت نظر در بازار به توسعه برنامه کمک کنید", next: "شروع", onNext: () { controller.next(); }, onSkip: () { controller.skip(); }, ); }, ), ]) ]); } @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { double width = constraints.maxWidth; bool maxWidth = width > 360 ? true : false; print(width); return Scaffold( backgroundColor: DarkMod == false ? const Color.fromARGB(255, 240, 240, 240) : Colors.grey[850], body: Directionality( textDirection: TextDirection.rtl, child: Stack( children: [ Positioned( top: MediaQuery.of(context).size.height * 0.2, left: 0, right: 0, child: Lottie.asset( 'assets/images/welcome1.json', width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.height * 0.3, fit: BoxFit.fill, ), ), Positioned( top: 0, left: 0, right: 0, child: ClipPath( clipper: WaveClipper(), child: Container( height: MediaQuery.of(context).size.height * 0.16, color: const Color.fromRGBO(112, 27, 248, 1), alignment: Alignment.center, child: const Text( 'درباره ما', style: TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, fontFamily: 'Iranian_Sans'), ), ), ), ), Positioned( top: MediaQuery.of(context).size.height * 0.5, left: 0, right: 0, child: Container( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Text( key: Samkey, 'SAM Studio', style: TextStyle( fontSize: maxWidth ? 22 : 12, fontWeight: FontWeight.bold, fontFamily: 'Iranian_Sans', color: DarkMod == false ? Colors.grey[850] : Colors.white, ), ), ), const SizedBox(height: 35), Padding( padding: const EdgeInsets.only(right: 20), key: telkey, child: Text( 'راههای ارتباطی:', style: TextStyle( fontSize: maxWidth ? 16 : 10, fontWeight: FontWeight.bold, fontFamily: 'Iranian_Sans', color: DarkMod == false ? Colors.grey[850] : Colors.white, ), ), ), const SizedBox(height: 10), Container( width: MediaQuery.of(context).size.width, child: Padding( padding: EdgeInsets.all( maxWidth ? 18 : 0, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ FittedBox( fit: BoxFit.contain, child: ElevatedButton( onPressed: () { _launchUrl(); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( Icons.telegram, color: const Color.fromRGBO( 112, 27, 248, 1), size: maxWidth ? 18 : 9, ), SizedBox( width: maxWidth ? 8 : 1, ), Text( 'تلگرام', style: TextStyle( fontSize: maxWidth ? 16 : 9, color: const Color.fromRGBO( 112, 27, 248, 1), ), ), ], ), ), ), Padding( padding: const EdgeInsets.only(right: 10), child: FittedBox( fit: BoxFit.contain, child: ElevatedButton( onPressed: () { Clipboard.setData(const ClipboardData( text: 'info@samstudio.app')); ScaffoldMessenger.of(context) .showSnackBar(const SnackBar( content: Text( 'ایمیل برای شما کپی شد', textDirection: TextDirection.rtl))); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( size: maxWidth ? 18 : 9, Icons.email, color: const Color.fromRGBO( 112, 27, 248, 1), ), SizedBox( width: maxWidth ? 8 : 1, ), Text( 'ایمیل', style: TextStyle( fontSize: maxWidth ? 16 : 9, color: const Color.fromRGBO( 112, 27, 248, 1), ), ), ], ), ), ), ), Padding( padding: const EdgeInsets.only(right: 10), child: FittedBox( fit: BoxFit.contain, child: ElevatedButton( onPressed: () { // _launchURL('https://eitaa.com/your_eitaa_handle'); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( size: maxWidth ? 18 : 9, Icons.message, color: const Color.fromRGBO( 112, 27, 248, 1), ), SizedBox( width: maxWidth ? 8 : 1, ), Text( 'ایتا', style: TextStyle( fontSize: maxWidth ? 16 : 9, color: const Color.fromRGBO( 112, 27, 248, 1), ), ), ], ), ), ), ), ], ), ), ), SizedBox( height: maxWidth ? 30 : 10, ), Center( key: bazarkey, child: ElevatedButton( onPressed: () { // _launchURL('https://cafebazaar.ir/app/your_app_id'); }, style: ElevatedButton.styleFrom( minimumSize: const Size(double.infinity, 50), backgroundColor: const Color.fromRGBO(112, 27, 248, 1), ), child: const Text( 'ثبت نظر در کافه بازار', style: TextStyle( fontSize: 20, color: Colors.white, fontWeight: FontWeight.bold, fontFamily: 'Iranian_Sans'), ), ), ), ], ), ), ), ], ), ), ); }); } Future<void> _launchUrl() async { if (!await launchUrl(_url)) { throw Exception('Could not launch $_url'); } } } class WaveClipper extends CustomClipper<Path> { @override Path getClip(Size size) { var path = Path(); path.lineTo(0, size.height - 50); path.quadraticBezierTo( size.width / 2, size.height, size.width, size.height - 50, ); path.lineTo(size.width, 0); path.close(); return path; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => true; } class CoachmarkDesc extends StatefulWidget { const CoachmarkDesc({ super.key, required this.text, this.skip = "رد کردن", this.next = "بعدی", this.onSkip, this.onNext, }); final String text; final String skip; final String next; final void Function()? onSkip; final void Function()? onNext; @override State<CoachmarkDesc> createState() => _CoachmarkDescState(); } class _CoachmarkDescState extends State<CoachmarkDesc> with SingleTickerProviderStateMixin { late AnimationController animationController; @override void initState() { animationController = AnimationController( vsync: this, lowerBound: 0, upperBound: 20, duration: const Duration(milliseconds: 800), )..repeat(reverse: true); super.initState(); } @override void dispose() { animationController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Directionality( textDirection: TextDirection.rtl, child: AnimatedBuilder( animation: animationController, builder: (context, child) { return Transform.translate( offset: Offset(0, animationController.value), child: child, ); }, child: Container( padding: const EdgeInsets.all(15), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( widget.text, style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( onPressed: widget.onSkip, child: Text(widget.skip), ), const SizedBox(width: 16), ElevatedButton( onPressed: widget.onNext, child: Text(widget.next), ), ], ), ], ), ), ), ); } }
1. Click on 'Users' in the left side panel > select 'All Users' 2. Under the name "Philip' click on Edit 3. Scroll down to the Role dropdown menu, select 'Administrator' 4. Then go further down and click on 'Update User' Please keep in mind that this gives full access in the site, if they don't want Philip to have full access they will need to change the access level again after the floating button has been added. Here's another option if they don't want to give full admin access but just give plugin permissions. 1. Click on 'Users' 2. Click on 'User Role Editor' 3. Depending on what Role Philip has, they can select that in the top dropdown menu where it says 'Select role and change capabilities' 4. On the left, click on 'Plugins' 5. Select the checkboxes 'Activate, Edit, Install, Delete plugins' 6. On the left again click on 'All' 7. Select the checkboxes 'Activate plugins, Edit plugins, Read 8. Click on 'Update' on the right
// your relationship public function books() { return $this->hasMany('App\Models\Book'); } // Get the first inserted child model public function first_book() { return $this->hasOne('App\Models\Book')->oldestOfMany(); } // Get the last inserted child model public function last_book() { return $this->hasOne('App\Models\Book')->latestOfMany(); }
Tue Sep 10 2024 13:30:15 GMT+0000 (Coordinated Universal Time) https://blockchain.oodles.io/telegram-mini-apps-development/?utm_source=thiscodeworks
Tue Sep 10 2024 12:59:53 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/54087631/paypal-sizeof-parameter-must-be-an-array-or-an-object-that-implements-countab
Tue Sep 10 2024 11:24:46 GMT+0000 (Coordinated Universal Time) https://magento.stackexchange.com/questions/318291/no-administrators-role-was-found-data-fixture-needs-to-be-run
Tue Sep 10 2024 10:51:38 GMT+0000 (Coordinated Universal Time) https://nounq.com/seo-services
Mon Sep 09 2024 19:24:25 GMT+0000 (Coordinated Universal Time) https://forum.moralis.io/t/walletconnect-connection-after-refresh/8815
Sun Sep 08 2024 04:46:36 GMT+0000 (Coordinated Universal Time)
@davidmchale #css #map-get #maps #object #loop #conditionals
Sat Sep 07 2024 16:55:45 GMT+0000 (Coordinated Universal Time) https://onlinetestseriesmadeeasy.in/madeeasy/index.php?pageName
Sat Sep 07 2024 13:09:16 GMT+0000 (Coordinated Universal Time) https://chatgpt.com/c/66d9c7f1-9ff4-8002-9f5c-fa4060f7338e
Sat Sep 07 2024 03:54:33 GMT+0000 (Coordinated Universal Time) https://exceloffthegrid.com/vba-for-customlists-autofill-lists/
Sat Sep 07 2024 03:52:51 GMT+0000 (Coordinated Universal Time) https://exceloffthegrid.com/vba-for-customlists-autofill-lists/
Sat Sep 07 2024 03:44:36 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/
Sat Sep 07 2024 00:10:53 GMT+0000 (Coordinated Universal Time) https://markdown-it.github.io/
Fri Sep 06 2024 13:49:09 GMT+0000 (Coordinated Universal Time) https://www.ntlite.com/community/index.php?threads/windows-11-setupcomplete-cmd-is-not-working.4773/#post-46440
Fri Sep 06 2024 13:22:56 GMT+0000 (Coordinated Universal Time) https://www.ntlite.com/community/index.php?threads/can-you-figure-this-out-other-user.4774/
Fri Sep 06 2024 12:59:25 GMT+0000 (Coordinated Universal Time) https://komododecks.com/recordings/MJCBACXOvUhFwXj6bxeC
@Y@sir #textrevealeffect] #texteffect #textrevealeffectusinggsap
Fri Sep 06 2024 12:29:42 GMT+0000 (Coordinated Universal Time) https://appticz.com/cash-app-clone
Fri Sep 06 2024 11:37:21 GMT+0000 (Coordinated Universal Time) https://www.ukassignmenthelp.uk/