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
| // Select all forms on the page | |
| const forms = document.querySelectorAll('form'); | |
| // Iterate over each form and attach a submit event listener | |
| forms.forEach(form => { | |
| form.addEventListener('submit', event => { | |
| event.preventDefault(); // Prevent the default form submission behavior | |
| // Get form data | |
| const formData = new FormData(form); |
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
| from http.server import BaseHTTPRequestHandler, HTTPServer | |
| import json | |
| class MyRequestHandler(BaseHTTPRequestHandler): | |
| def _set_headers(self, status_code=200, content_type='text/html'): | |
| self.send_response(status_code) | |
| self.send_header('Content-type', content_type) | |
| self.end_headers() | |
| def do_GET(self): |
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 Phaser from "phaser"; | |
| function preload() { | |
| this.load.image("sky", "Assets/sky.png"); | |
| this.load.image("ground", "Assets/platform.png"); | |
| this.load.image("star", "Assets/star.png"); | |
| this.load.image("bomb", "Assets/bomb.png"); | |
| this.load.spritesheet("dude", "Assets/dude.png", { | |
| frameWidth: 32, | |
| frameHeight: 48, |
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
| // This code takes values put in to column A, and applies a formula to calculate column B. | |
| // The result of the formula, not the formula, is added to column B. | |
| function onEdit(e) { | |
| var range = e.range; | |
| var sheet = range.getSheet(); | |
| var row = range.getRow(); | |
| var col = range.getColumn(); | |
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
| function stringToNumber(inputString) { | |
| let hash = 0; | |
| for (let i = 0; i < inputString.length; i++) { | |
| const charCode = inputString.charCodeAt(i); | |
| hash = (hash << 5) - hash + charCode; | |
| } | |
| hash = Math.abs(hash); | |
| return hash; | |
| } |
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
| function myFunction() { | |
| let sheet = SpreadsheetApp.getActiveSheet(); | |
| let address = sheet.getRange("A1").getValue(); | |
| let subject = sheet.getRange("A2").getValue(); | |
| let body = sheet.getRange("A3").getValue(); | |
| MailApp.sendEmail(address, subject, body); | |
| } |
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 pandas as pd | |
| import requests | |
| import re | |
| def get_final_url(url): | |
| response = requests.get(url, allow_redirects=True) | |
| return response.url | |
| # Load the CSV file | |
| file_path = 'sf housing - list.csv' |
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 { initializeApp } from "firebase/app"; | |
| import { getFirestore, collection, getDocs } from 'firebase/firestore/lite'; | |
| import { getAuth, signInWithCustomToken } from "firebase/auth"; | |
| import { firebaseConfig } from "../config/firebase" | |
| import { useAuth } from "@clerk/clerk-react"; | |
| import { useEffect, useState } from "react"; | |
| // Initialize Firebase app with the provided configuration |
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
| function detectPopularLanguages(codeSnippet: string): string[] { | |
| const languageKeywords: { [key: string]: RegExp } = { | |
| JavaScript: /\b(?:var|let|const|function|if|else|for|while|switch|case|break|return)\b/g, | |
| Python: /\b(?:def|if|elif|else|for|while|break|continue|return)\b/g, | |
| Java: /\b(?:public|private|protected|class|void|static|if|else|for|while|switch|case|break|return)\b/g, | |
| CSharp: /\b(?:public|private|protected|class|void|static|if|else|for|while|switch|case|break|return)\b/g, | |
| C: /\b(?:int|float|char|void|if|else|for|while|switch|case|break|return)\b/g, | |
| Ruby: /\b(?:def|if|else|elsif|unless|end|for|while|case|when)\b/g, | |
| PHP: /\b(?:public|private|protected|function|if|else|for|while|switch|case|break|return)\b/g, | |
| Swift: /\b(?:class|func|var|let|if|else|for|while|switch|case|break|return)\b/g, |
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
| pragma solidity ^0.8.0; | |
| contract MyToken { | |
| mapping(address => uint) public balanceOf; | |
| constructor(uint _initialSupply) { | |
| balanceOf[msg.sender] = _initialSupply; | |
| } | |
| function transfer(address _to, uint _value) public { |