Skip to content

Instantly share code, notes, and snippets.

View devstar0209's full-sized avatar

devstar0209

View GitHub Profile
@devstar0209
devstar0209 / autofill-remove-bg.css
Created August 29, 2024 01:10
Prevent autocomplete and ignore background color in autofill
autocomplete="nope"
autocomplete="new-password"
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
appearance: menulist-button;
background-color: rgb(232, 240, 254) !important; /* Light theme background color */
-webkit-text-fill-color: #ffffff !important;
-webkit-caret-color: white !important;
@devstar0209
devstar0209 / Launcher.java
Created July 16, 2024 03:45
Launch another app from your app app in parallel
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
if (packageName != null && !packageName.equals("")) {
intent.setPackage(packageName);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // add this line to lanuch in parallel or comment if launch inside your app.
// intent.putExtras(extras);
startActivity(intent);
@devstar0209
devstar0209 / browser_platform.js
Created May 22, 2024 06:34
Get platform of a web browser
function getPlatform() {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Check for iOS
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return 'iOS';
}
// Check for Android
if (/android/i.test(userAgent)) {
@devstar0209
devstar0209 / numberInput.css
Created March 15, 2024 02:22
Hide spin in number input
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
@devstar0209
devstar0209 / dots.css
Created March 15, 2024 02:21
3 dots text
{
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
color: #63b5ff;
}
@devstar0209
devstar0209 / required.css
Created March 15, 2024 02:19
Add red * for a required input field
.required : after{
content:'*';
color:red;
padding-left: 2px;
}
@devstar0209
devstar0209 / json.php
Created March 15, 2024 02:16
Fetch json object in text
preg_match('~\{(?:[^{}]|(?R))*\}~', $message, $res);
$response = json_decode($res[0], true);
var forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.prototype.slice.call(forms)
.forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
@devstar0209
devstar0209 / file-input.html
Created March 13, 2024 11:58
Customize file input
<div class="form-control d-flex justify-content-between align-items-center">
<input hidden type="file" accept=".pdf,.png,.jpeg,.jpg" name="bankFile" id="bankFile" class="form-control" required>
<p>{{__('BANK ac proof')}}</p>
<label for="bankFile" class="btn btn-light btn-sm">Upload</label>
</div>
<script>
$('input[type="file"]').on('change', function() {
$(this).next().html($(this).val().split("\\").splice(-1,1)[0] || "Select file");
});
@devstar0209
devstar0209 / WriteCSV.py
Last active March 4, 2024 02:16
Write to CSV file using python
# Write data to CSV file using csv lib
import csv
header = ['Name', 'M1 Score', 'M2 Score']
data = [['Alex', 62, 80], ['Brad', 45, 56], ['Joey', 85, 98]]
filename = 'Students_Data.csv'
with open(filename, 'w', newline="") as file:
csvwriter = csv.writer(file) ## 2. create a csvwriter object
csvwriter.writerow(header) ## 4. write the header
csvwriter.writerows(data)