repo
stringlengths
8
123
branch
stringclasses
178 values
readme
stringlengths
1
441k
description
stringlengths
1
350
topics
stringlengths
10
237
createdAt
stringlengths
20
20
lastCommitDate
stringlengths
20
20
lastReleaseDate
stringlengths
20
20
contributors
int64
0
10k
pulls
int64
0
3.84k
commits
int64
1
58.7k
issues
int64
0
826
forks
int64
0
13.1k
stars
int64
2
49.2k
diskUsage
float64
license
stringclasses
24 values
language
stringclasses
80 values
waylaidwanderer/node-chatgpt-api
main
<p align="center"> <img alt="CLI demo" src="./demos/cli.gif"> </p> ## Updates <details open> <summary><strong>2023-03-01</strong></summary> **Support for the official ChatGPT model has been added!** You can now use the `gpt-3.5-turbo` model with the official OpenAI API, using `ChatGPTClient`. This is the same model that ChatGPT uses, and it's the most powerful model available right now. Usage of this model is **not free**, however it is **10x cheaper** (priced at $0.002 per 1k tokens) than `text-davinci-003`. See OpenAI's post, [Introducing ChatGPT and Whisper APIs](https://openai.com/blog/introducing-chatgpt-and-whisper-apis) for more information. ~~To use it, set `modelOptions.model` to `gpt-3.5-turbo`, and `ChatGPTClient` will handle the rest.~~ The default model used in `ChatGPTClient` is now `gpt-3.5-turbo`. You can still set `userLabel`, `chatGptLabel` and `promptPrefix` (system instructions) as usual. **There may be a higher chance of your account being banned if you continue to automate chat.openai.com.** Continue doing so at your own risk. </details> <details> <summary><strong>Previous Updates</strong></summary> <br/> <details> <summary><strong>2023-02-19</strong></summary> I've added an experimental `ChatGPTBrowserClient` which depends on a reverse proxy server that makes use of a Cloudflare bypass, allowing you to talk to ChatGPT (chat.openai.com) without requiring browser automation. All you need is your access token from https://chat.openai.com/api/auth/session. As always, please note that if you choose to go this route, you are exposing your access token to a closed-source third-party server. If you are concerned about this, you may choose to either use a free ChatGPT account to minimize risks, or continue using `ChatGPTClient` instead with the `text-davinci-003` model. </details> <details> <summary><strong>2023-02-15</strong></summary> The method we were using to access the ChatGPT underlying models has been patched, unfortunately. Your options right now are to either use the official OpenAI API with the `text-davinci-003` model (which costs money), or use a browser-based solution to interface with ChatGPT's backend (which is less powerful, more rate-limited and is not supported by this library at this time). </details> <details> <summary><strong>2023-02-11</strong></summary> With the help of @PawanOsman, **we've figured out a way to continue using the ChatGPT underlying models**. To hopefully prevent losing access again, we've decided to provide reverse proxy servers compatible with the OpenAI API. I've updated `ChatGPTClient` to support using a reverse proxy server instead of the OpenAI API server. See [Using a Reverse Proxy](#using-a-reverse-proxy) for more information on available proxy servers and how they work. Please note that if you choose to go this route, you are exposing your access token to a closed-source third-party server. If you are concerned about this, you may choose to either use a free ChatGPT account to minimize risks, or continue using the official OpenAI API instead with the `text-davinci-003` model. </details> <details> <summary><strong>2023-02-10</strong></summary> ~~I've found a new working model for `text-chat-davinci-002`, `text-chat-davinci-002-sh-alpha-aoruigiofdj83`. This is the underlying model that the ChatGPT Plus "Turbo" version uses. Responses are blazing fast. I've updated the library to use this model.~~ Bad timing; `text-chat-davinci-002-sh-alpha-aoruigiofdj83` was removed shortly after, possibly due to a new model somewhere out there? </details> <details> <summary><strong>2023-02-09</strong></summary> Experience the power of Bing's GPT-4 version of ChatGPT with [`BingAIClient`](src/BingAIClient.js) (experimental). **The ~~API server and~~ CLI still need to be updated to support this**, but you can [use the client](#module) directly right now. *Please note that if your account is still wait-listed, you will not be able to use this client.* </details> <details> <summary><strong>2023-02-08</strong></summary> Even though `text-chat-davinci-002-20221122` is back up again, it seems like it's constantly overloaded and returns a 429 error. It's likely that OpenAI only dedicated a small amount of resources to this model to prevent it being widely used by the public. Additionally, I've heard that newer versions are now access-locked to OpenAI employees and partners, so it's unlikely that we'll be able to find any workarounds until the model is officially released. You may use the `text-davinci-003` model instead as a drop-in replacement. Keep in mind that `text-davinci-003` is not as good as `text-chat-davinci-002` (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still pretty good in most cases. **Please note that using `text-davinci-003` will cost you credits ($).** I will be re-adding support for the browser-based ChatGPT for the API server and CLI. Please star and watch this repository for updates. </details> <details> <summary><strong>2023-02-07</strong></summary> The roller coaster has reached the next stop. `text-chat-davinci-002-20221122` is back up again. ~~Trying to use `text-chat-davinci-002-20221122` with the OpenAI API now returns a 404 error. You may use the `text-davinci-003` model instead as a drop-in replacement. Keep in mind that `text-davinci-003` is not as good as `text-chat-davinci-002` (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still very good. **Please note that using `text-davinci-003` will cost you credits ($).**~~ ~~Please hold for further updates as we investigate further workarounds.~~ </details> <details> <summary><strong>2023-02-02</strong></summary> ~~Trying to use `text-chat-davinci-002-20230126` with the OpenAI API now returns a 404 error. Someone has already found the new model name, but they are unwilling to share at this time. I will update this repository once I find the new model. If you have any leads, please open an issue or a pull request.~~ ~~In the meantime, I've added support for models like `text-davinci-003`, which you can use as a drop-in replacement. Keep in mind that `text-davinci-003` is not as good as `text-chat-davinci-002` (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still very good. **Please note that using `text-davinci-003` will cost you credits ($).**~~ Discord user @pig#8932 has found a working `text-chat-davinci-002` model, `text-chat-davinci-002-20221122`. I've updated the library to use this model. </details> </details> # ChatGPT API > A client implementation for ChatGPT and Bing AI. Available as a Node.js module, REST API server, and CLI app. [![NPM](https://img.shields.io/npm/v/@waylaidwanderer/chatgpt-api.svg)](https://www.npmjs.com/package/@waylaidwanderer/chatgpt-api) [![npm](https://img.shields.io/npm/dt/@waylaidwanderer/chatgpt-api)](https://www.npmjs.com/package/@waylaidwanderer/chatgpt-api) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/waylaidwanderer/node-chatgpt-api/blob/main/LICENSE) [![GitHub Repo stars](https://img.shields.io/github/stars/waylaidwanderer/node-chatgpt-api)](https://github.com/waylaidwanderer/node-chatgpt-api/) # Table of Contents * [Features](#features) * [Getting Started](#getting-started) * [Prerequisites](#prerequisites) * [Usage](#usage) * [Module](#module) * [API Server](#api-server) * [CLI](#cli) * [Using a Reverse Proxy](#using-a-reverse-proxy) * [Projects](#projects) * [Web Client](#web-client) * [Caveats](#caveats) * [Contributing](#contributing) * [License](#license) ## Features - Includes an API server (with Docker support) you can run to use ChatGPT in non-Node.js applications. - Includes a CLI interface where you can chat with ChatGPT. - Includes clients that you can use in your own Node.js applications. - `ChatGPTClient`: support for the official ChatGPT underlying model, `gpt-3.5-turbo`, via OpenAI's API. - Replicates chat threads from the official ChatGPT website (with conversation IDs and message IDs), with persistent conversations using [Keyv](https://www.npmjs.com/package/keyv). - Conversations are stored in memory by default, but you can optionally [install a storage adapter](https://www.npmjs.com/package/keyv#usage) to persist conversations to a database. - The `keyv-file` adapter is also included in this package, and can be used to store conversations in a JSON file if you're using the API server or CLI (see `settings.example.js`). - Supports configurable prompt prefixes, and custom names for the user and ChatGPT. - In essence, this allows you to make a chatbot with any personality you want. - This is currently only configurable on a global level, but I plan to add support for per-conversation customization. - Retains support for models like `text-davinci-003` - `BingAIClient`: support for Bing's version of ChatGPT, powered by GPT-4. - Includes a built-in jailbreak you can activate which enables unlimited chat messages per conversation, unlimited messages per day, and brings Sydney back. 😊 - `ChatGPTBrowserClient`: support for the official ChatGPT website, using a reverse proxy server for a Cloudflare bypass. - **There may be a high chance of your account being banned if you continue to automate chat.openai.com.** Continue doing so at your own risk. ## Getting Started ### Prerequisites - Node.js >= 16.0.0 - npm - Docker (optional, for API server) - [OpenAI API key](https://platform.openai.com/account/api-keys) ## Usage ### Module ```bash npm i @waylaidwanderer/chatgpt-api ``` <details open> <summary><strong>BingAIClient</strong></summary> See [`demos/use-bing-client.js`](demos/use-bing-client.js). </details> <details open> <summary><strong>ChatGPTClient</strong></summary> See [`demos/use-client.js`](demos/use-client.js). </details> <details open> <summary><strong>ChatGPTBrowserClient</strong></summary> See [`demos/use-browser-client.js`](demos/use-browser-client.js). </details> ### API Server <h4 id="api-server-setup">Setup</h4> You can install the package using ```bash npm i -g @waylaidwanderer/chatgpt-api ``` then run it using `chatgpt-api`. This takes an optional `--settings=<path_to_settings.js>` parameter, or looks for `settings.js` in the current directory if not set, with the following contents: <details> <summary><strong>settings.js</strong></summary> ```JS module.exports = { // Options for the Keyv cache, see https://www.npmjs.com/package/keyv. // This is used for storing conversations, and supports additional drivers (conversations are stored in memory by default). // Only necessary when using `ChatGPTClient`, or `BingAIClient` in jailbreak mode. cacheOptions: {}, // If set, `ChatGPTClient` and `BingAIClient` will use `keyv-file` to store conversations to this JSON file instead of in memory. // However, `cacheOptions.store` will override this if set storageFilePath: process.env.STORAGE_FILE_PATH || './cache.json', chatGptClient: { // Your OpenAI API key (for `ChatGPTClient`) openaiApiKey: process.env.OPENAI_API_KEY || '', // (Optional) Support for a reverse proxy for the completions endpoint (private API server). // Warning: This will expose your `openaiApiKey` to a third party. Consider the risks before using this. // reverseProxyUrl: 'https://chatgpt.hato.ai/completions', // (Optional) Parameters as described in https://platform.openai.com/docs/api-reference/completions modelOptions: { // You can override the model name and any other parameters here. // The default model is `gpt-3.5-turbo`. model: 'gpt-3.5-turbo', // Set max_tokens here to override the default max_tokens of 1000 for the completion. // max_tokens: 1000, }, // (Optional) Davinci models have a max context length of 4097 tokens, but you may need to change this for other models. // maxContextTokens: 4097, // (Optional) You might want to lower this to save money if using a paid model like `text-davinci-003`. // Earlier messages will be dropped until the prompt is within the limit. // maxPromptTokens: 3097, // (Optional) Set custom instructions instead of "You are ChatGPT...". // (Optional) Set a custom name for the user // userLabel: 'User', // (Optional) Set a custom name for ChatGPT ("ChatGPT" by default) // chatGptLabel: 'Bob', // promptPrefix: 'You are Bob, a cowboy in Western times...', // A proxy string like "http://<ip>:<port>" proxy: '', // (Optional) Set to true to enable `console.debug()` logging debug: false, }, // Options for the Bing client bingAiClient: { // Necessary for some people in different countries, e.g. China (https://cn.bing.com) host: '', // The "_U" cookie value from bing.com userToken: '', // If the above doesn't work, provide all your cookies as a string instead cookies: '', // A proxy string like "http://<ip>:<port>" proxy: '', // (Optional) Set to true to enable `console.debug()` logging debug: false, }, chatGptBrowserClient: { // (Optional) Support for a reverse proxy for the conversation endpoint (private API server). // Warning: This will expose your access token to a third party. Consider the risks before using this. reverseProxyUrl: 'https://bypass.churchless.tech/api/conversation', // Access token from https://chat.openai.com/api/auth/session accessToken: '', // Cookies from chat.openai.com (likely not required if using reverse proxy server). cookies: '', // A proxy string like "http://<ip>:<port>" proxy: '', // (Optional) Set to true to enable `console.debug()` logging debug: false, }, // Options for the API server apiOptions: { port: process.env.API_PORT || 3000, host: process.env.API_HOST || 'localhost', // (Optional) Set to true to enable `console.debug()` logging debug: false, // (Optional) Possible options: "chatgpt", "chatgpt-browser", "bing". (Default: "chatgpt") clientToUse: 'chatgpt', // (Optional) Generate titles for each conversation for clients that support it (only ChatGPTClient for now). // This will be returned as a `title` property in the first response of the conversation. generateTitles: false, // (Optional) Set this to allow changing the client or client options in POST /conversation. // To disable, set to `null`. perMessageClientOptionsWhitelist: { // The ability to switch clients using `clientOptions.clientToUse` will be disabled if `validClientsToUse` is not set. // To allow switching clients per message, you must set `validClientsToUse` to a non-empty array. validClientsToUse: ['bing', 'chatgpt', 'chatgpt-browser'], // values from possible `clientToUse` options above // The Object key, e.g. "chatgpt", is a value from `validClientsToUse`. // If not set, ALL options will be ALLOWED to be changed. For example, `bing` is not defined in `perMessageClientOptionsWhitelist` above, // so all options for `bingAiClient` will be allowed to be changed. // If set, ONLY the options listed here will be allowed to be changed. // In this example, each array element is a string representing a property in `chatGptClient` above. chatgpt: [ 'promptPrefix', 'userLabel', 'chatGptLabel', // Setting `modelOptions.temperature` here will allow changing ONLY the temperature. // Other options like `modelOptions.model` will not be allowed to be changed. // If you want to allow changing all `modelOptions`, define `modelOptions` here instead of `modelOptions.temperature`. 'modelOptions.temperature', ], }, }, // Options for the CLI app cliOptions: { // (Optional) Possible options: "chatgpt", "bing". // clientToUse: 'bing', }, }; ``` </details> Alternatively, you can install and run the package directly. 1. Clone this repository: `git clone https://github.com/waylaidwanderer/node-chatgpt-api` 2. Install dependencies with `npm install` (if not using Docker) 3. Rename `settings.example.js` to `settings.js` in the root directory and change the settings where required. 4. Start the server: - using `npm start` or `npm run server` (if not using Docker) - using `docker-compose up` (requires Docker) #### Endpoints <details> <summary><strong>POST /conversation</strong></summary> Start or continue a conversation. Optional parameters are only necessary for conversations that span multiple requests. | Field | Description | |---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | message | The message to be displayed to the user. | | conversationId | (Optional) An ID for the conversation you want to continue. | | jailbreakConversationId | (Optional, for `BingAIClient` only) Set to `true` to start a conversation in jailbreak mode. After that, this should be the ID for the jailbreak conversation (given in the response as a parameter also named `jailbreakConversationId`). | | parentMessageId | (Optional, for `ChatGPTClient`, and `BingAIClient` in jailbreak mode) The ID of the parent message (i.e. `response.messageId`) when continuing a conversation. | | conversationSignature | (Optional, for `BingAIClient` only) A signature for the conversation (given in the response as a parameter also named `conversationSignature`). Required when continuing a conversation unless in jailbreak mode. | | clientId | (Optional, for `BingAIClient` only) The ID of the client. Required when continuing a conversation unless in jailbreak mode. | | invocationId | (Optional, for `BingAIClient` only) The ID of the invocation. Required when continuing a conversation unless in jailbreak mode. | | clientOptions | (Optional) An object containing options for the client. | | clientOptions.clientToUse | (Optional) The client to use for this message. Possible values: `chatgpt`, `chatgpt-browser`, `bing`. | | clientOptions.* | (Optional) Any valid options for the client. For example, for `ChatGPTClient`, you can set `clientOptions.openaiApiKey` to set an API key for this message only, or `clientOptions.promptPrefix` to give the AI custom instructions for this message only, etc. | To configure which options can be changed per message (default: all), see the comments for `perMessageClientOptionsWhitelist` in `settings.example.js`. To allow changing clients, `perMessageClientOptionsWhitelist.validClientsToUse` must be set to a non-empty array as described in the example settings file. </details> #### Usage <details> <summary><strong>Method 1 (POST)</strong></summary> To start a conversation with ChatGPT, send a POST request to the server's `/conversation` endpoint with a JSON body with parameters per **Endpoints** > **POST /conversation** above. ```JSON { "message": "Hello, how are you today?", "conversationId": "your-conversation-id (optional)", "parentMessageId": "your-parent-message-id (optional, for `ChatGPTClient` only)", "conversationSignature": "your-conversation-signature (optional, for `BingAIClient` only)", "clientId": "your-client-id (optional, for `BingAIClient` only)", "invocationId": "your-invocation-id (optional, for `BingAIClient` only)", } ``` The server will return a JSON object containing ChatGPT's response: ```JS // HTTP/1.1 200 OK { "response": "I'm doing well, thank you! How are you?", "conversationId": "your-conversation-id", "messageId": "response-message-id (for `ChatGPTClient` only)", "conversationSignature": "your-conversation-signature (for `BingAIClient` only)", "clientId": "your-client-id (for `BingAIClient` only)", "invocationId": "your-invocation-id (for `BingAIClient` only - pass this new value back into subsequent requests as-is)", "details": "an object containing the raw response from the client" } ``` If the request is unsuccessful, the server will return a JSON object with an error message. If the request object is missing a required property (e.g. `message`): ```JS // HTTP/1.1 400 Bad Request { "error": "The message parameter is required." } ``` If there was an error sending the message to ChatGPT: ```JS // HTTP/1.1 503 Service Unavailable { "error": "There was an error communicating with ChatGPT." } ``` </details> <details> <summary><strong>Method 2 (SSE)</strong></summary> You can set `"stream": true` in the request body to receive a stream of tokens as they are generated. ```js import { fetchEventSource } from '@waylaidwanderer/fetch-event-source'; // use `@microsoft/fetch-event-source` instead if in a browser environment const opts = { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ "message": "Write a poem about cats.", "conversationId": "your-conversation-id (optional)", "parentMessageId": "your-parent-message-id (optional)", "stream": true, // Any other parameters per `Endpoints > POST /conversation` above }), }; ``` See [demos/use-api-server-streaming.js](demos/use-api-server-streaming.js) for an example of how to receive the response as it's generated. You will receive one token at a time, so you will need to concatenate them yourself. Successful output: ```JS { data: '', event: '', id: '', retry: 3000 } { data: 'Hello', event: '', id: '', retry: undefined } { data: '!', event: '', id: '', retry: undefined } { data: ' How', event: '', id: '', retry: undefined } { data: ' can', event: '', id: '', retry: undefined } { data: ' I', event: '', id: '', retry: undefined } { data: ' help', event: '', id: '', retry: undefined } { data: ' you', event: '', id: '', retry: undefined } { data: ' today', event: '', id: '', retry: undefined } { data: '?', event: '', id: '', retry: undefined } { data: '<result JSON here, see Method 1>', event: 'result', id: '', retry: undefined } { data: '[DONE]', event: '', id: '', retry: undefined } // Hello! How can I help you today? ``` Error output: ```JS const message = { data: '{"code":503,"error":"There was an error communicating with ChatGPT."}', event: 'error', id: '', retry: undefined }; if (message.event === 'error') { console.error(JSON.parse(message.data).error); // There was an error communicating with ChatGPT. } ``` </details> #### Notes - Method 1 is simple, but Time to First Byte (TTFB) is long. - Method 2 uses a non-standard implementation of [server-sent event API](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events); you should import `fetch-event-source` first and use `POST` method. ### CLI #### Setup Follow the same [setup instructions](#api-server-setup) for the API server, creating `settings.js`. #### Usage If installed globally: ```bash chatgpt-cli ``` If installed locally: ```bash npm run cli ``` ChatGPT's responses are automatically copied to your clipboard, so you can paste them into other applications. ## Using a Reverse Proxy As shown in the examples above, you can set `reverseProxyUrl` in `ChatGPTClient`'s options to use a reverse proxy server instead of the official ChatGPT API. ~~For now, **this is the only way to use the ChatGPT underlying models**.~~ This method has been patched and the instructions below are no longer relevant, but you may still want to use a reverse proxy for other reasons. Currently, reverse proxy servers are still used for performing a Cloudflare bypass for `ChatGPTBrowserClient`. <details> <summary><strong>Instructions</strong></summary> How does it work? Simple answer: `ChatGPTClient` > reverse proxy > OpenAI server. The reverse proxy server does some magic under the hood to access the underlying model directly via OpenAI's server and then returns the response to `ChatGPTClient`. Instructions are provided below. <details open> <summary><strong>https://chatgpt.hato.ai/completions</strong> (mine, <strong>currently offline</strong>)</summary> #### Instructions 1. Get your ChatGPT access token from https://chat.openai.com/api/auth/session (look for the `accessToken` property). * **This is NOT the same thing as the _session token_.** * Automatically fetching or refreshing your ChatGPT access token is not currently supported by this library. Please handle this yourself for now. 2. Set `reverseProxyUrl` to `https://chatgpt.hato.ai/completions` in `settings.js > chatGptClient` or `ChatGPTClient`'s options. 3. Set the "OpenAI API key" parameter (e.g. `settings.chatGptClient.openaiApiKey`) to the ChatGPT access token you got in step 1. 4. Set the `model` to `text-davinci-002-render`, `text-davinci-002-render-paid`, or `text-davinci-002-render-sha` depending on which ChatGPT models that your account has access to. Models **must** be a ChatGPT model name, not the underlying model name, and you cannot use a model that your account does not have access to. * You can check which ones you have access to by opening DevTools and going to the Network tab. Refresh the page and look at the response body for https://chat.openai.com/backend-api/models. #### Notes - Since this is my server, I can guarantee that no logging or tracking is done. I can see general usage stats, but I cannot see any of your completions. Whether you trust me on this or not is up to you. - Non-streaming responses over 60s are not supported. Use `stream: true` (API) or `onProgress` (client) as a workaround. - Rate limit of 10 requests per second. </details> <details open> <summary><strong>https://chatgpt.pawan.krd/api/completions</strong> (@PawanOsmon, <strong>currently offline</strong>)</summary> #### Instructions 1. Get your ChatGPT access token from https://chat.openai.com/api/auth/session (look for the `accessToken` property). * **This is NOT the same thing as the _session token_.** * Automatically fetching or refreshing your ChatGPT access token is not currently supported by this library. Please handle this yourself for now. 2. Set `reverseProxyUrl` to `https://chatgpt.pawan.krd/api/completions` in `settings.js > chatGptClient` or `ChatGPTClient`'s options. 3. Set the "OpenAI API key" parameter (e.g. `settings.chatGptClient.openaiApiKey`) to the ChatGPT access token you got in step 1. 4. Set the `model` to `text-davinci-002-render`, `text-davinci-002-render-paid`, or `text-davinci-002-render-sha` depending on which ChatGPT models that your account has access to. Models **must** be a ChatGPT model name, not the underlying model name, and you cannot use a model that your account does not have access to. * You can check which ones you have access to by opening DevTools and going to the Network tab. Refresh the page and look at the response body for https://chat.openai.com/backend-api/models. #### Notes - Non-streaming responses over 60s are not supported. Use `stream: true` (API) or `onProgress` (client) as a workaround. - Rate limit of 50 requests per 15 seconds. </details> </details> ## Projects 🚀 A list of awesome projects using `@waylaidwanderer/chatgpt-api`: - [PandoraAI](https://github.com/waylaidwanderer/PandoraAI): my web chat client powered by node-chatgpt-api, allowing users to easily chat with multiple AI systems while also offering support for custom presets. With its seamless and convenient design, PandoraAI provides an engaging conversational AI experience. - [LibreChat](https://github.com/danny-avila/chatgpt-clone): integrates ChatGPT technology, enabling multiple AI models, conversation features, message search, and plugins. It offers free/pay-per-call APIs, eliminating ChatGPT Plus need, and supports customization. - [ChatGPT WebApp](https://github.com/frontend-engineering/chatgpt-webapp-fullstack): a fullstack chat webapp with mobile compatble UI interface, and node-chatgpt-api works as backend. Anyone can deploy your own chat service. - [halbot](https://github.com/Leask/halbot): Just another ChatGPT/Bing Chat Telegram bot, which is simple design, easy to use, extendable and fun. - [ChatGPTBox](https://github.com/josStorer/chatGPTBox): Integrating ChatGPT into your browser deeply, everything you need is here - [llm-bot](https://github.com/Erisfiregamer1/llm-bot): A Discord bot for LLM nonsense. Comes with a custom reverse proxy for GPT-4 allowing it to be accessed for free (Thank you "generic")! - [WhatsAppSydney](https://github.com/veigamann/sydney-whatsapp-chatbot): Bing-powered personal assistant for WhatsApp. Simplify your day-to-day with ease. Add yours to the list by [editing this README](https://github.com/waylaidwanderer/node-chatgpt-api/edit/main/README.md) and creating a pull request! ## Web Client A web client for this project is also available at [waylaidwanderer/PandoraAI](https://github.com/waylaidwanderer/PandoraAI). ## Caveats ### Regarding `ChatGPTClient` Since `gpt-3.5-turbo` is ChatGPT's underlying model, I had to do my best to replicate the way the official ChatGPT website uses it. This means my implementation or the underlying model may not behave exactly the same in some ways: - Conversations are not tied to any user IDs, so if that's important to you, you should implement your own user ID system. - ChatGPT's model parameters (temperature, frequency penalty, etc.) are unknown, so I set some defaults that I thought would be reasonable. - Conversations are limited to roughly the last 3000 tokens, so earlier messages may be forgotten during longer conversations. - This works in a similar way to ChatGPT, except I'm pretty sure they have some additional way of retrieving context from earlier messages when needed (which can probably be achieved with embeddings, but I consider that out-of-scope for now). ## Contributing If you'd like to contribute to this project, please create a pull request with a detailed description of your changes. ## License This project is licensed under the MIT License.
A client implementation for ChatGPT and Bing AI. Available as a Node.js module, REST API server, and CLI app.
chatgpt,chatgpt-api,gpt,openai,openai-api,api,api-rest,api-server,cli,nodejs
2023-01-07T04:35:34Z
2023-10-10T21:53:44Z
2023-05-31T21:29:52Z
35
227
546
48
738
4,189
null
MIT
JavaScript
Exafunction/codeium.vim
main
<p align="center"> <img width="300" alt="Codeium" src="codeium.svg"/> </p> --- [![Discord](https://img.shields.io/discord/1027685395649015980?label=community&color=5865F2&logo=discord&logoColor=FFFFFF)](https://discord.gg/3XFf78nAx5) [![Twitter Follow](https://img.shields.io/badge/style--blue?style=social&logo=twitter&label=Follow%20%40codeiumdev)](https://twitter.com/intent/follow?screen_name=codeiumdev) ![License](https://img.shields.io/github/license/Exafunction/codeium.vim) [![built with Codeium](https://codeium.com/badges/main)](https://codeium.com?repo_name=exafunction%2Fcodeium.vim) [![Visual Studio](https://img.shields.io/visual-studio-marketplace/i/Codeium.codeium?label=Visual%20Studio&logo=visualstudio)](https://marketplace.visualstudio.com/items?itemName=Codeium.codeium) [![JetBrains](https://img.shields.io/jetbrains/plugin/d/20540?label=JetBrains)](https://plugins.jetbrains.com/plugin/20540-codeium/) [![Open VSX](https://img.shields.io/open-vsx/dt/Codeium/codeium?label=Open%20VSX)](https://open-vsx.org/extension/Codeium/codeium) [![Google Chrome](https://img.shields.io/chrome-web-store/users/hobjkcpmjhlegmobgonaagepfckjkceh?label=Google%20Chrome&logo=googlechrome&logoColor=FFFFFF)](https://chrome.google.com/webstore/detail/codeium/hobjkcpmjhlegmobgonaagepfckjkceh) # codeium.vim _Free, ultrafast Copilot alternative for Vim and Neovim_ Codeium autocompletes your code with AI in all major IDEs. We [launched](https://www.codeium.com/blog/codeium-copilot-alternative-in-vim) this implementation of the Codeium plugin for Vim and Neovim to bring this modern coding superpower to more developers. Check out our [playground](https://www.codeium.com/playground) if you want to quickly try out Codeium online. Contributions are welcome! Feel free to submit pull requests and issues related to the plugin. <br /> ![Example](https://user-images.githubusercontent.com/1908017/213154744-984b73de-9873-4b85-998f-799d92b28eec.gif) <br /> ## 🚀 Getting started 1. Install [Vim](https://github.com/vim/vim) (at least 9.0.0185) or [Neovim](https://github.com/neovim/neovim/releases/latest) (at least 0.6) 2. Install `Exafunction/codeium.vim` using your vim plugin manager of choice, or manually. See [Installation Options](#-installation-options) below. 3. Run `:Codeium Auth` to set up the plugin and start using Codeium. You can run `:help codeium` for a full list of commands and configuration options, or see [this guide](https://www.codeium.com/vim_tutorial) for a quick tutorial on how to use Codeium. ## 🛠️ Configuration For a full list of configuration options you can run `:help codeium`. A few of the most popular options are highlighted below. ### ⌨️ Keybindings Codeium provides the following functions to control suggestions: | Action | Function | Default Binding | | --------------------------- | ------------------------------ | --------------- | | Clear current suggestion | `codeium#Clear()` | `<C-]>` | | Next suggestion | `codeium#CycleCompletions(1)` | `<M-]>` | | Previous suggestion | `codeium#CycleCompletions(-1)` | `<M-[>` | | Insert suggestion | `codeium#Accept()` | `<Tab>` | | Manually trigger suggestion | `codeium#Complete()` | `<M-Bslash>` | Codeium's default keybindings can be disabled by setting ```vim let g:codeium_disable_bindings = 1 ``` or in Neovim: ```lua vim.g.codeium_disable_bindings = 1 ``` If you'd like to just disable the `<Tab>` binding, you can alternatively use the `g:codeium_no_map_tab` option. If you'd like to bind the actions above to different keys, this might look something like the following in Vim: ```vim imap <script><silent><nowait><expr> <C-g> codeium#Accept() imap <C-;> <Cmd>call codeium#CycleCompletions(1)<CR> imap <C-,> <Cmd>call codeium#CycleCompletions(-1)<CR> imap <C-x> <Cmd>call codeium#Clear()<CR> ``` Or in Neovim (using [wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim#specifying-plugins) or [folke/lazy.nvim](https://github.com/folke/lazy.nvim)): ```lua -- Remove the `use` here if you're using folke/lazy.nvim. use { 'Exafunction/codeium.vim', config = function () -- Change '<C-g>' here to any keycode you like. vim.keymap.set('i', '<C-g>', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true }) vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true, silent = true }) vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true, silent = true }) vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true }) end } ``` (Make sure that you ran `:Codeium Auth` after installation.) ### ⛔ Disabling Codeium Codeium can be disabled for particular filetypes by setting the `g:codeium_filetypes` variable in your vim config file (vimrc/init.vim): ```vim let g:codeium_filetypes = { \ "bash": v:false, \ "typescript": v:true, \ } ``` Codeium is enabled by default for most filetypes. You can also _disable_ codeium by default with the `g:codeium_enabled` variable, and enable it manually per buffer by running `:CodeiumEnable`: ```vim let g:codeium_enabled = v:false ``` or in Neovim: ```lua vim.g.codeium_enabled = false ``` Or you can disable codeium for _all filetypes_ with the `g:codeium_filetypes_disabled_by_default` variable, and use the `g:codeium_filetypes` variable to selectively enable codeium for specified filetypes: ```vim " let g:codeium_enabled = v:true let g:codeium_filetypes_disabled_by_default = v:true let g:codeium_filetypes = { \ "rust": v:true, \ "typescript": v:true, \ } ``` If you would like to just disable the automatic triggering of completions: ```vim let g:codeium_manual = v:true " You might want to use `CycleOrComplete()` instead of `CycleCompletions(1)`. " This will make the forward cycling of suggestions also trigger the first " suggestion manually. imap <C-;> <Cmd>call codeium#CycleOrComplete()<CR> ``` To disable automatic text rendering of suggestions (the gray text that appears for a suggestion): ```vim let g:codeium_render = v:false ``` ### Show Codeium status in statusline Codeium status can be generated by calling the `codeium#GetStatusString()` function. In Neovim, you can use `vim.api.nvim_call_function("codeium#GetStatusString", {})` instead. It produces a 3 char long string with Codeium status: - `'3/8'` - third suggestion out of 8 - `'0'` - Codeium returned no suggestions - `'*'` - waiting for Codeium response In normal mode, status shows if Codeium is enabled or disabled by showing `'ON'` or `'OFF'`. In order to show it in status line add following line to your `.vimrc`: ```set statusline+=\{…\}%3{codeium#GetStatusString()}``` Shorter variant without Codeium logo: ```set statusline+=%3{codeium#GetStatusString()}``` Please check `:help statusline` for further information about building statusline in VIM. vim-airline supports Codeium out-of-the-box since commit [3854429d](https://github.com/vim-airline/vim-airline/commit/3854429d99c8a2fb555a9837b155f33c957a2202). ### Launching Codeium Chat Calling the `codeium#Chat()` function will enable search and indexing in the current project and launch Codeium Chat in a new browser window. The project root is determined by looking in Vim's current working directory for some specific files or directories to be present and goes up to parent directories until one is found. This list of hints is user-configurable and the default value is: ```let g:codeium_workspace_root_hints = ['.bzr','.git','.hg','.svn','_FOSSIL_','package.json']``` Note that launching chat enables telemetry. ## 💾 Installation Options ### 💤 Lazy ```lua { 'Exafunction/codeium.vim', event = 'BufEnter' } ``` ### 🔌 vim-plug ```vim Plug 'Exafunction/codeium.vim', { 'branch': 'main' } ``` ### 📦 Vundle ```vim Plugin 'Exafunction/codeium.vim' ``` ### 📦 packer.nvim: ```vim use 'Exafunction/codeium.vim' ``` ### 💪 Manual #### 🖥️ Vim Run the following. On windows, you can replace `~/.vim` with `$HOME/vimfiles`: ```bash git clone https://github.com/Exafunction/codeium.vim ~/.vim/pack/Exafunction/start/codeium.vim ``` #### 💻 Neovim Run the following. On windows, you can replace `~/.config` with `$HOME/AppData/Local`: ```bash git clone https://github.com/Exafunction/codeium.vim ~/.config/nvim/pack/Exafunction/start/codeium.vim ```
Free, ultrafast Copilot alternative for Vim and Neovim
autocomplete,copilot,go,golang,javascript,neovim,python,typescript,vim,codeium
2023-01-03T19:24:30Z
2024-05-03T19:48:56Z
null
39
168
173
69
116
3,470
null
MIT
Vim Script
themesberg/flowbite-admin-dashboard
main
# [Flowbite Admin Dashboard](https://flowbite-admin-dashboard.vercel.app) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&logo=twitter)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fthemesberg%2Fflowbite-admin-dashboard&text=Check%20out%20this%20open-source%20admin%20dashboard%20built%20with%20Flowbite%20and%20Tailwind%20CSS) [![version](https://img.shields.io/npm/v/flowbite-admin-dashboard)](https://www.npmjs.com/package/flowbite-admin-dashboard) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) [![GitHub issues open](https://img.shields.io/github/issues/themesberg/flowbite-admin-dashboard.svg)](https://github.com/themesberg/flowbite-admin-dashboard/issues?q=is%3Aopen+is%3Aissue) [![GitHub issues closed](https://img.shields.io/github/issues-closed-raw/themesberg/flowbite-admin-dashboard.svg)](https://github.com/themesberg/flowbite-admin-dashboard/issues?q=is%3Aissue+is%3Aclosed) [![Flowbite Admin Dashboard Live Preview](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/flowbite-admin-dashboard-preview.png)](https://flowbite-admin-dashboard.vercel.app/) This project is a free and open-source UI admin dashboard template built with the components from [Flowbite](https://github.com/themesberg/flowbite) and based on the utility-first [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) framework featuring charts, tables, widgets, CRUD layouts, modals, drawers, and more. This admin dashboard can quickly help you get started building an application for your project using the newest UI/UX development technologies in the open-source area including Tailwind CSS and Flowbite. ## 🌀 Built with Flowbite The interactive components such as the navbars, modals, drawers, and tooltips are all based on the popular [open-source component library called Flowbite](https://flowbite.com/) which enables us to use these elements by creating more complex set of pages and widgets inside a fully-fledged admin dashboard template. ## 💨 Tailwind CSS utility classes All of the pages, widgets, and components are solely based on the utility-first classes from Tailwind CSS and it is compatible with the latest `v3.x` of the technology by automatically purging all of the classes based on the template paths. ## 📊 15 example pages Get started with 15 advanced examples pages including two different layouts of a dashboard's homepage full of charts widgets, tables, datepickers, and statistics and also with two CRUD layout pages for products, users, a settings page, authentication pages for login and register and even custom 404 and 500 error pages. ## 🧱 Advanced components This admin dashboard contains many advanced components both from Flowbite but also from other third-party libraries such as ApexCharts which have been customly tailored with Tailwind CSS classes and designed based on the [Flowbite Design System](https://flowbite.com/figma/). ## 📚 Flowbite documentation If you want to use this project we recommend to also [study the component library](https://flowbite.com/docs/getting-started/introduction/) that we used to build this dashboard because you can use even more components from that library to enhance the examples that we've coded here already. ## ⚙️ Workflow This product is built using the following widely used technologies: - Tailwind CSS: [tailwindcss.com](https://tailwindcss.com/) - Flowbite: [flowbite.com](http://flowbite.com/) - HUGO [gohugo.io](https://gohugo.io/documentation/) - Webpack [webpack.js.org](https://webpack.js.org/) ## Table of Contents - [Flowbite Admin Dashboard ](#flowbite-admin-dashboard-) - [🌀 Built with Flowbite](#-built-with-flowbite) - [💨 Tailwind CSS utility classes](#-tailwind-css-utility-classes) - [📊 15 example pages](#-15-example-pages) - [🧱 Advanced components](#-advanced-components) - [📚 Flowbite documentation](#-flowbite-documentation) - [⚙️ Workflow](#️-workflow) - [Table of Contents](#table-of-contents) - [Demo pages](#demo-pages) - [Quick start](#quick-start) - [JavaScript Frameworks](#javascript-frameworks) - [Back-end Frameworks](#back-end-frameworks) - [File Structure](#file-structure) - [Browser Support](#browser-support) - [Resources](#resources) - [Reporting Issues](#reporting-issues) - [Technical Support or Questions](#technical-support-or-questions) - [Licensing](#licensing) - [Useful Links](#useful-links) - [Authors](#authors) ## Demo pages | Dashboard | Stacked Layout | Products (CRUD) | --- | --- | --- | | [![Dashboard](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/homepage.jpg)](https://flowbite-admin-dashboard.vercel.app/) | [![Stacked Layout](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/stacked.jpg)](https://flowbite-admin-dashboard.vercel.app/layouts/stacked/) | [![Products (CRUD)](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/products-crud.jpg)](https://flowbite-admin-dashboard.vercel.app/crud/products/) | Users (CRUD) | Settings | Pricing page | --- | --- | --- | | [![Users (CRUD)](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/users.jpg)](https://flowbite-admin-dashboard.vercel.app/crud/users/) | [![Settings](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/settings.jpg)](https://flowbite-admin-dashboard.vercel.app/settings/) | [![Pricing page](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/pricing.jpg)](https://flowbite-admin-dashboard.vercel.app/pages/pricing/) | Login page | Register page | Reset password | --- | --- | --- | | [![Login page](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/login.jpg)](https://flowbite-admin-dashboard.vercel.app/authentication/sign-in/) | [![Register page](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/register.jpg)](https://flowbite-admin-dashboard.vercel.app/authentication/sign-up/) | [![Reset password](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/reset-password.jpg)](https://flowbite-admin-dashboard.vercel.app/authentication/reset-password/) | Forgot password | Profile lock | Maintenance page | --- | --- | --- | | [![Forgot password](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/forgot-password.jpg)](https://flowbite-admin-dashboard.vercel.app/authentication/forgot-password/) | [![Profile lock](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/profile-lock.jpg)](https://flowbite-admin-dashboard.vercel.app/authentication/profile-lock/) | [![Maintenance page](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/maintenance.jpg)](https://flowbite-admin-dashboard.vercel.app/pages/maintenance/) | 404 not found | 500 server error | Playground | --- | --- | --- | | [![404 not found](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/404.jpg)](https://flowbite-admin-dashboard.vercel.app/pages/404/) | [![500 server error](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/500.jpg)](https://flowbite-admin-dashboard.vercel.app/pages/500/) | [![Playground](https://flowbite.s3.amazonaws.com/templates/flowbite-admin-dashboard/github/playground.jpg)](https://flowbite-admin-dashboard.vercel.app/playground/sidebar/) - [Live Preview](https://flowbite-admin-dashboard.vercel.app/) ## Quick start 1. Clone this repository or download the ZIP file 2. Make sure that you have Node.js and NPM installed 3. Install the project dependencies from the `package.json` file: ``` npm install ``` 4. Create a local server on `localhost:1313` by running the following command: ``` npm run start ``` You can also build the project and get the distribution files inside the `public/` folder by running: ``` npm run build ``` You can instantly upload your project to Vercel by selecting the default HUGO configuration, but depending on your own tech stack whether it's React.js, Vue, Nuxt.js, Next.js or a back-end framework you can also just copy the layouts from this project inside your own tech stack. Here's a list of compatible technologies and guides for Flowbite and Tailwind CSS: ### JavaScript Frameworks The awesome open-source community also built and currently maintains the following standalone libraries for React, Vue, Svelte, and Angular: - [🌀 Flowbite React Library](https://github.com/themesberg/flowbite-react) - [🍀 Flowbite Vue Library](https://github.com/themesberg/flowbite-vue) - [🎸 Flowbite Svelte Library](https://github.com/themesberg/flowbite-svelte) - [📕 Flowbite Angular Library](https://github.com/themesberg/flowbite-angular) We also wrote integration guides for the following front-end frameworks and libraries: - [📝 Flowbite with React guide](https://flowbite.com/docs/getting-started/react/) - [📝 Flowbite with Next.js guide](https://flowbite.com/docs/getting-started/next-js/) - [📝 Flowbite with Vue guide](https://flowbite.com/docs/getting-started/vue/) - [📝 Flowbite with Nuxt.js guide](https://flowbite.com/docs/getting-started/nuxt-js/) - [📝 Flowbite with Svelte guide](https://flowbite.com/docs/getting-started/svelte/) ### Back-end Frameworks Flowbite has a great integration with most of the back-end frameworks because it relies on vanilla JavaScript: - [📚 Using Flowbite with Laravel](https://flowbite.com/docs/getting-started/laravel/) - [🚊 Using Flowbite with Ruby on Rails 7](https://flowbite.com/docs/getting-started/rails/) - [🐸 Using Flowbite with Django](https://flowbite.com/docs/getting-started/django/) - [🌶 Using Flowbite with Flask](https://flowbite.com/docs/getting-started/flask/) ## File Structure Within the download you'll find the following directories and files: ``` Flowbite Admin Dashboard . ├── LICENSE ├── README.md ├── config.yml ├── content ├── data ├── layouts ├── node_modules ├── package-lock.json ├── package.json ├── postcss.config.js ├── resources ├── src ├── static ├── tailwind.config.js ├── webpack.config.js └── yarn.lock ``` ## Browser Support At present, we officially aim to support the last two versions of the following browsers: <img src="https://s3.amazonaws.com/creativetim_bucket/github/browser/chrome.png" width="64" height="64"> <img src="https://s3.amazonaws.com/creativetim_bucket/github/browser/firefox.png" width="64" height="64"> <img src="https://s3.amazonaws.com/creativetim_bucket/github/browser/edge.png" width="64" height="64"> <img src="https://s3.amazonaws.com/creativetim_bucket/github/browser/safari.png" width="64" height="64"> <img src="https://s3.amazonaws.com/creativetim_bucket/github/browser/opera.png" width="64" height="64"> ## Resources - Live preview: <https://flowbite-admin-dashboard.vercel.app/> - Flowbite documentation: <https://flowbite.com/docs/getting-started/introduction/> - Tailwind CSS documentation: <https://tailwindcss.com/> - License Agreement: <https://flowbite.com/docs/getting-started/license/> - Issues: [Github Issues Page](https://github.com/themesberg/flowbite-admin-dashboard/issues) ## Reporting Issues We use GitHub Issues as the official bug tracker for Flowbite Admin Dashboard. Here are some advices for our users that want to report an issue: 1. Make sure that you are using the latest version of Flowbite Admin Dashboard. Check the CHANGELOG from your dashboard on the [GitHub releases page](https://github.com/themesberg/flowbite-admin-dashboard/releases). 2. Providing us reproducible steps for the issue will shorten the time it takes for it to be fixed. 3. Some issues may be browser specific, so specifying in what browser you encountered the issue might help. ## Technical Support or Questions If you have questions or need help integrating the product please [contact us](https://flowbite.com/contact/) instead of opening an issue. ## Licensing - Copyright 2019-2023 Bergside Inc. (https://flowbite.com) - Open-source under the [MIT License](https://github.com/themesberg/flowbite-admin-dashboard/blob/main/LICENSE) ## Useful Links - 📚 [Flowbite Library](https://flowbite.com/) - Open-source components built with Tailwind CSS - 🎨 [Flowbite Figma](https://flowbite.com/figma/) - Design system built for Figma - 🧱 [Flowbite Blocks](https://flowbite.com/blocks/) - Building sections for website and applications - 💎 [Flowbite Pro](https://flowbite.com/pro/) - A larger collection of the open-source version of the latter three ## Authors - [Zoltán Szőgyényi](https://twitter.com/zoltanszogyenyi) - [Robert Tanislav](https://twitter.com/roberttanislav)
Free and open-source admin dashboard template built with Tailwind CSS and Flowbite
admin-dashboard,charts,css,dashboard,flowbite,html,hugo,javascript,tailwind,tailwindcss
2023-01-09T15:52:21Z
2023-11-10T11:01:13Z
2023-01-16T20:42:56Z
2
5
82
10
403
1,691
null
MIT
HTML
sumn2u/learn-javascript
main
# Learn JavaScript [![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) [![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/) [![GitHub issues](https://img.shields.io/github/issues/sumn2u/learn-javascript)](https://github.com/sumn2u/learn-javascript/issues) [![GitHub forks](https://img.shields.io/github/forks/sumn2u/learn-javascript)](https://github.com/sumn2u/learn-javascript/network) [![GitHub stars](https://img.shields.io/github/stars/sumn2u/learn-javascript)](https://github.com/sumn2u/learn-javascript/stargazers) [![GitHub license](https://img.shields.io/github/license/sumn2u/learn-javascript)](https://github.com/sumn2u/learn-javascript/blob/master/LICENSE) [![Twitter](https://img.shields.io/twitter/url/https/github.com/sumn2u/bagchal.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fsumn2u%2Flearn-javascript) [![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7372/badge)](https://bestpractices.coreinfrastructure.org/projects/7372) [![Open Source Helpers](https://www.codetriage.com/sumn2u/learn-javascript/badges/users.svg)](https://www.codetriage.com/sumn2u/learn-javascript) ## Overview **This book offers a comprehensive introduction to programming and JavaScript, designed to impart fundamental knowledge in a clear and organized manner. Its content delves into foundational principles and core concepts, presented in simple language to facilitate easy comprehension. The book is thoughtfully structured, providing in-depth explanations and accompanying notes enriched with illustrative examples, thereby enhancing the reader's understanding of the subject matter. Furthermore, the inclusion of practical exercises at the end of each section adds significant value to the learning experience, allowing readers to apply the acquired knowledge and reinforce their skills. This thoughtful combination of theoretical explanations, real-world examples, and hands-on exercises ensures a well-rounded educational approach, making the book an invaluable resource for beginners looking to grasp the essentials of programming and JavaScript in a professional and systematic manner.** ## Table of Contents 1. [Introduction](#introduction) 2. [Typographic Conventions](#typographic-conventions) 3. [Support the Project](#support-the-project) 4. [Installation and Usage Instructions](#installation-and-usage-instructions) 5. [Structure](#structure) 6. [Contributing Guidelines](#contributing-guidelines) 7. [Contributors](#contributors) 8. [Contact Us](#contact-us) 9. [License Information](#license-information) ## 📚 Introduction <a name="introduction"></a> **Learn JavaScript: Beginners Guide** provides a foundational understanding of programming and JavaScript. It covers the core concepts in a simple and organized manner, offering in-depth information and notes along with examples to facilitate comprehension. Each chapter includes exercises to reinforce your learning. **What You'll Learn** 😎 This meticulously crafted book caters to a diverse audience, ranging from novice learners taking their first steps into the world of programming to seasoned developers seeking to enhance their skills specifically in the domain of JavaScript. Its strength lies in providing a thorough and inclusive initiation into the JavaScript programming language. The book's structure is intelligently organized into three distinct sections, each catering to different aspects of JavaScript learning. The first part, comprising the initial 14 chapters, meticulously covers the fundamental concepts of JavaScript. These chapters are designed to build a strong foundation, ensuring that readers, regardless of their prior experience, grasp the core principles of the language comprehensively. Moving forward, the subsequent four chapters transition seamlessly into the realm of web browser programming using JavaScript. This section not only imparts theoretical knowledge but also provides practical insights into real-world applications, enabling readers to understand how JavaScript functions within the context of web development. The book doesn't merely stop at the basics; it goes the extra mile by dedicating the final two chapters to miscellaneous topics that are pivotal in mastering JavaScript. **🚀 Code, and What to Do With It** Code is the heart of any program, and this book contains numerous code examples. To master programming, it's essential to read and write code diligently. Don't rush through the examples; take your time to understand them thoroughly. The same applies to the exercises – attempt to solve them before checking the solutions. Consider running your code in a JavaScript interpreter to ensure it works correctly. Experimenting and going beyond the exercises will enhance your skills. By adding emojis and organizing the content, you can make the text more engaging and visually appealing. ## Typographic conventions In this book, text written in a monospaced font represents elements of a program. This can be a self-contained fragment or a reference to part of a nearby program. Programs, like the one shown below, are written in this way: ```javascript const numbers = [45, 4, 9, 16, 25]; let txt = ""; for (let x in numbers) { txt += numbers[x]; } ``` Sometimes, the expected output of a program is written after it, preceded by two slashes with a _Result_, like this: ```javascript console.log(txt); // Result: txt = '45491625' ``` ## Support the Project <a name="support-the-project"></a>⭐ If you feel awesome and want to support us in a small way, please consider starring and sharing the repo! This helps us get visibility and allow the community to grow. 🙏 <img alt="star_us" width="250" src="./star_us.gif"> ## Installation and Usage Instructions To get started with this project, follow these steps: 1. Clone this repository. 2. Move to the 'learn-javascript' directory. 3. Install dependencies using `yarn` or `npm install`. 4. Run `yarn start` command. 5. Visit http://localhost:4000 for a preview. ## Structure The main contents are under the charset of each language directory . For English, use `en` directory. directory | description learn-javascript ├── _book # compiled version of contents ├── _layouts # layout for rendering book/website ├── en # content of book in english language ├── fr # content of book in french language ├── np # content of book in nepali language ├── tr # content of book in turkish language ├── LANGS.md # supported languages ├── books # books in pdf and epub formats with translation ├── book.json # configuration for book └── ... ## Contributing Guidelines Contributions to this project are welcome. If you want to contribute, follow these steps: 1. Create an issue to discuss your proposed changes or improvements. 2. Fork and clone the repository. 3. Make your changes locally. 4. Push your changes and create a pull request. **Tips** *For Adding new documents* : Create `*.md` file under `<lang>/chapter-<n>/` directory. ## Contributors We would like to thank the open-source community for their valuable contributions to this project [![](https://contributors-img.web.app/image?repo=sumn2u/learn-javascript)](https://github.com/sumn2u/learn-javascript/graphs/contributors) ## Contact Us If you have any questions or feedback, please don't hesitate to contact us at sumn2u@gmail.com, or reach out to Suman directly. We hope you find this resource helpful 💜. ## License Information This project is licensed under the [Apache License 2.0](./LICENSE) , which means that you are free to use, modify, and distribute the code as long as you comply with the terms of the license.
A book that teaches JavaScript
js,learning,javascript,open-source,programming-language,collaborate,github,student-vscode,beginner,learn-javascript
2023-01-01T15:16:26Z
2024-05-03T11:24:17Z
2024-03-26T18:26:51Z
51
126
366
21
122
846
null
Apache-2.0
HTML
imsyy/SPlayer
dev
# SPlayer > 一个简约的音乐播放器 ![main](/screenshots/SPlayer.jpg) ## 说明 > [!IMPORTANT] > > ### 严肃警告 > > - 请务必遵守 [GNU Affero General Public License (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html) 许可协议 > - 在您的修改、演绎、分发或派生项目中,必须同样采用 **AGPL-3.0** 许可协议,**并在适当的位置包含本项目的许可和版权信息** > - **禁止用于售卖或其他商业用途**,如若发现,作者保留追究法律责任的权利 > - 若发现未遵守 **AGPL-3.0** 许可协议的行为,**本项目将永久停更** > - 感谢您的尊重与理解 - 本项目采用 [Vue 3](https://cn.vuejs.org/) 全家桶和 [Naïve UI](https://www.naiveui.com/) 组件库及 [Electron](https://www.electronjs.org/zh/docs/latest/) 开发 - 支持网页端与客户端,由于设备有限,目前仅适配 `Win`,其他平台可自行解决兼容性后进行构建 - 仅对移动端做了基础适配,**不保证功能全部可用** > 请注意,本程序不打算开发移动端,也不会对移动端进行完美适配,仅保证基础可用性 - 欢迎各位大佬 `Star` 😍 ## 👀 Demo - [SPlayer](https://music.imsyy.top/) ## 🎉 功能 - ✨ 支持扫码登录 - 📱 支持手机号登录 - 📅 自动进行每日签到及云贝签到 - 🎨 封面主题色自适应 - 🌚 Light / Dark 模式自动切换 - 📁 本地歌曲管理及分类(建议先使用 [音乐标签](https://www.cnblogs.com/vinlxc/p/11347744.html) 进行匹配后再使用) - 🎵 **支持播放部分无版权歌曲(可能会与原曲不匹配,客户端独占功能)** - ⬇️ 下载歌曲(最高支持 Hi-Res) - ➕ 新建歌单及歌单编辑 - ❤️ 收藏 / 取消收藏歌单或歌手 - 🎶 每日推荐歌曲 - 📻 私人 FM - ☁️ 云盘音乐上传 - 📂 云盘内歌曲播放 - 🔄 云盘内歌曲纠正 - 🗑️ 云盘歌曲删除 - 📝 支持逐字歌词 - 🔄 歌词滚动以及歌词翻译 - 📹 MV 与视频播放 - 🎶 音乐频谱显示 - ⏭️ 音乐渐入渐出 - 🔄 支持 PWA - 💬 支持评论区及评论点赞 - 🌓 明暗模式自动 / 手动切换 - 📱 移动端基础适配 - ~~🌐 `i18n` 支持~~ ## 🖼️ Screenshots > 开发中,仅供参考 <details> <summary>主页面</summary> ![主页面](/screenshots/SPlayer%20-%20主页面.jpg) </details> <details> <summary>播放页面</summary> ![播放页面](/screenshots/SPlayer%20-%20播放页面.jpg) </details> <details> <summary>发现页面</summary> ![发现页面](/screenshots/SPlayer%20-%20发现页面.jpg) </details> <details> <summary>歌单页面</summary> ![发现页面](/screenshots/SPlayer%20-%20歌单页面.jpg) </details> <details> <summary>评论页面</summary> ![发现页面](/screenshots/SPlayer%20-%20评论页面.jpg) </details> <details> <summary>本地音乐</summary> ![发现页面](/screenshots/SPlayer%20-%20本地音乐.jpg) </details> ## 📦️ 获取 ### 稳定版 通常情况下,可以在 [Releases](https://github.com/imsyy/SPlayer/releases) 中获取稳定版 ### 开发版 可以通过 `GitHub Actions` 工作流获取最新的开发版,目前开发版仅提供 `Win` 版本 [Dev Workflow](https://github.com/imsyy/SPlayer/actions/workflows/build.yml) ## ⚙️ Docker 部署 > 安装及配置 `Docker` 将不在此处说明,请自行解决 ### 本地构建 > 请尽量拉取最新分支后使用本地构建方式,在线部署的仓库可能更新不及时 ```bash # 构建 docker build -t splayer . # 运行 docker run -d --name SPlayer -p 7899:7899 splayer # 或使用 Docker Compose docker-compose up -d ``` ### 在线部署 ```bash # 从 Docker Hub 拉取 docker pull imsyy/splayer:latest # 从 GitHub ghcr 拉取 docker pull ghcr.io/imsyy/splayer:latest # 运行 docker run -d --name SPlayer -p 7899:7899 imsyy/splayer:latest ``` 以上步骤成功后,将会在本地 [localhost:7899](http://localhost:7899/) 启动,如需更换端口,请自行修改命令行中的端口号 ## ⚙️ Vercel 部署 > 其他部署平台大致相同,在此不做说明 1. 本程序依赖 [NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi) 运行,请确保您已成功部署该项目,并成功取得在线访问地址 2. 点击本仓库右上角的 `Fork`,复制本仓库到你的 `GitHub` 账号 3. 复制 `/.env.example` 文件并重命名为 `/.env` 4. 将 `.env` 文件中的 `RENDERER_VITE_SERVER_URL` 改为第一步得到的 API 地址 ```js RENDERER_VITE_SERVER_URL = "https://example.com"; ``` 5. 将 `Build and Output Settings` 中的 `Output Directory` 改为 `out/renderer` ![build](/screenshots/build.png) 6. 点击 `Deploy`,即可成功部署 ## ⚙️ 服务器部署 1. 重复 `⚙️ Vercel 部署` 中的 1 - 4 步骤 2. 克隆仓库 > 将链接中的 example/repository.git 替换为你要克隆的实际仓库的地址 ```bash git clone https://github.com/example/repository.git ``` 3. 安装依赖 ```bash pnpm install # 或者 yarn install # 或者 npm install ``` 4. 编译打包 ```bash pnpm build # 或者 yarn build # 或者 npm build ``` 5. 将站点运行目录设置为 `out/renderer` 目录 ## ⚙️ 本地部署 1. 本地部署需要用到 `Node.js`。可前往 [Node.js 官网](https://nodejs.org/zh-cn/) 下载安装包,请下载最新稳定版 2. 安装 pnpm ```bash npm install pnpm -g ``` 3. 克隆仓库并拉取至本地,此处不再赘述 4. 使用 `pnpm install` 安装项目依赖(若安装过程中遇到网络错误,请使用国内镜像源替代,此处不再赘述) 5. 复制 `/.env.example` 文件并重命名为 `/.env` 并修改配置 6. 打包客户端,请依据你的系统类型来选择,打包成功后,会输出安装包或可执行文件在 `/dist` 目录中,可自行安装 | 命令 | 系统类型 | | ------------------ | -------- | | `pnpm build:win` | Windows | | `pnpm build:linux` | Linux | | `pnpm build:mac` | MacOS | ## 😘 鸣谢 特此感谢为本项目提供支持与灵感的项目 - [NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi) - [YesPlayMusic](https://github.com/qier222/YesPlayMusic) - [UnblockNeteaseMusic](https://github.com/UnblockNeteaseMusic/server) - [Vue-mmPlayer](https://github.com/maomao1996/Vue-mmPlayer) ## 📢 免责声明 本项目部分功能使用了网易云音乐的第三方 API 服务,**仅供个人学习研究使用,禁止用于商业及非法用途** 同时,本项目开发者承诺 **严格遵守相关法律法规和网易云音乐 API 使用协议,不会利用本项目进行任何违法活动。** 如因使用本项目而引起的任何纠纷或责任,均由使用者自行承担。**本项目开发者不承担任何因使用本项目而导致的任何直接或间接责任,并保留追究使用者违法行为的权利** 请使用者在使用本项目时遵守相关法律法规,**不要将本项目用于任何商业及非法用途。如有违反,一切后果由使用者自负。** 同时,使用者应该自行承担因使用本项目而带来的风险和责任。本项目开发者不对本项目所提供的服务和内容做出任何保证 感谢您的理解 ## 📜 开源许可 - **本项目仅供个人学习研究使用,禁止用于商业及非法用途** - 本项目基于 [GNU Affero General Public License (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html) 许可进行开源 1. **修改和分发:** 任何对本项目的修改和分发都必须基于 AGPL-3.0 进行,源代码必须一并提供 2. **派生作品:** 任何派生作品必须同样采用 AGPL-3.0,并在适当的地方注明原始项目的许可证 3. **注明原作者:** 在任何修改、派生作品或其他分发中,必须在适当的位置明确注明原作者及其贡献 4. **免责声明:** 根据 AGPL-3.0,本项目不提供任何明示或暗示的担保。请详细阅读 [GNU Affero General Public License (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html) 以了解完整的免责声明内容 5. **社区参与:** 欢迎社区的参与和贡献,我们鼓励开发者一同改进和维护本项目 6. **许可证链接:** 请阅读 [GNU Affero General Public License (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html) 了解更多详情 ## 📂 目录结构 <details> <summary>查看目录结构详情</summary> > ChatGPT 写的,如有错误,请见谅 ```dir ├── auto-imports.d.ts # 自动导入 ├── components.d.ts # 自动导入 ├── docker-compose.yml # Docker Compose ├── Dockerfile # Docker ├── electron # Electron │   ├── main # Electron 主进程 │   │   ├── index.js # 主进程入口 │   │   ├── mainIpcMain.js # 主进程与渲染进程通信 │   │   ├── startMainServer.js # 启动主进程服务器 │   │   ├── startNcmServer.js # 启动网易云音乐服务 │   │   └── utils # 主进程工具函数 │   │   ├── checkUpdates.js # 检查更新 │   │   ├── createGlobalShortcut.js # 创建全局快捷键 │   │   ├── createSystemTray.js # 创建系统托盘 │   │   ├── getNeteaseMusicUrl.js # 解灰 │   │   ├── kwDES.js # DES加密算法 │   │   └── readDirAsync.js # 异步读取目录 │   └── preload # Electron 预加载脚本 │   └── index.js # 预加载脚本入口文件 ├── electron-builder.yml # Electron Builder ├── electron.vite.config.js # Electron Vite ├── index.html # 主页面 HTML ├── LICENSE # 项目许可证 ├── nginx.conf # Nginx 配置 ├── src # 项目源代码 │   ├── api # API 相关 │   │   ├── ./.. │   ├── App.vue # 根组件 │   ├── assets # 静态资源 │   │   ├── emoji.json # 表情数据 │   │   ├── icon.json # 图标数据 │   │   └── themeColor.json # 主题颜色数据 │   ├── components # 组件目录 │   │   ├── Cover # 封面相关组件目录 │   │   │   ├── CoverDropdown.vue # 封面下拉组件 │   │   │   ├── MainCover.vue # 主封面组件 │   │   │   ├── SpecialCoverCard.vue # 特殊封面卡片组件 │   │   │   └── SpecialCover.vue # 特殊封面组件 │   │   ├── Global # 全局组件目录 │   │   │   ├── MainLayout.vue # 主布局组件 │   │   │   ├── Menu.vue # 菜单组件 │   │   │   ├── Pagination.vue # 分页组件 │   │   │   ├── Playlist.vue # 歌单组件 │   │   │   ├── Provider.vue # 全局化配置组件 │   │   │   └── SvgIcon.vue # SVG 图标组件 │   │   ├── List # 列表组件目录 │   │   │   ├── CommentList.vue # 评论列表组件 │   │   │   ├── SongListDropdown.vue # 歌曲下拉组件 │   │   │   └── SongList.vue # 歌曲列表组件 │   │   ├── Modal # 弹窗相关组件目录 │   │   │   ├── AddPlaylist.vue # 添加歌单组件 │   │   │   ├── CloudSongMatch.vue # 云盘歌曲匹配组件 │   │   │   ├── CreatePlaylist.vue # 创建歌单组件 │   │   │   ├── DownloadSong.vue # 下载歌曲组件 │   │   │   ├── LoginPhone.vue # 手机登录组件 │   │   │   ├── LoginQRCode.vue # 二维码登录组件 │   │   │   ├── Login.vue # 登录组件 │   │   │   ├── PlaylistUpdate.vue # 歌单编辑组件 │   │   │   └── UpCloudSong.vue # 上传云盘歌曲组件 │   │   ├── Nav # 导航相关组件目录 │   │   │   ├── MainNav.vue # 主导航组件 │   │   │   └── UserData.vue # 用户数据组件 │   │   ├── Player # 播放器相关组件目录 │   │   │   ├── CountDown.vue # 倒计时组件 │   │   │   ├── FullPlayer.vue # 全屏播放器组件 │   │   │   ├── Lyric.vue # 歌词组件 │   │   │   ├── MainControl.vue # 主控制组件 │   │   │   ├── PlayerControl.vue # 播放器控制组件 │   │   │   ├── PlayerCover.vue # 播放器封面组件 │ │ │ └── PrivateFm.vue # 私人 FM 组件 │ │ ├── Search # 搜索相关组件 │ │ │ ├── SearchHot.vue # 热门搜索组件 │ │ │ ├── SearchInp.vue # 搜索输入组件 │ │ │ └── SearchSuggestions.vue # 搜索建议组件 │ │ └── WinDom # 窗口 DOM 相关组件 │ │ └── TitleBar.vue # 标题栏组件 │ ├── main.js # Vue 应用的入口文件 │ ├── router # Vue Router 相关文件夹 │ │ ├── index.js # Vue Router 入口文件 │ │ └── routes.js # 路由配置文件 │ ├── stores # Vuex Store 相关文件夹 │ │ ├── indexedDB.js # IndexedDB 数据库相关文件 │ │ ├── index.js # Vuex Store 入口文件 │ │ ├── musicData.js # 音乐数据相关文件 │ │ ├── siteData.js # 网站数据相关文件 │ │ ├── siteSettings.js # 网站设置相关文件 │ │ └── siteStatus.js # 网站状态相关文件 │ ├── style # 样式相关文件夹 │ │ ├── animate.scss # 动画样式文件 │ │ └── main.scss # 主样式文件 │ ├── utils # 工具函数文件夹 │ │ ├── auth.js # 认证相关函数 │ │ ├── base64.js # Base64编码解码相关函数 │ │ ├── color-utils.js # 颜色工具函数 │ │ ├── cover-color.js # 封面颜色相关函数 │ │ ├── debounce.js # 防抖函数 │ │ ├── formatData.js # 数据格式化函数 │ │ ├── formRules.js # 表单验证规则 │ │ ├── globalEvents.js # 全局事件处理函数 │ │ ├── globalShortcut.js # 全局快捷键相关函数 │ │ ├── helper.js # 辅助函数 │ │ ├── parseLyric.js # 解析歌词函数 │ │ ├── Player.js # 播放器控制相关函数 │ │ ├── request.js # 网络请求相关函数 │ │ ├── throttle.js # 节流函数 │ │ ├── timeTools.js # 时间工具函数 │ │ └── userSignIn.js # 用户登录相关函数 │ └── views # Vue组件文件夹 │ ├── Artist # 艺术家相关组件 │ │ ├── albums.vue # 艺术家专辑组件 │ │ ├── hot.vue # 艺术家热门组件 │ │ ├── index.vue # 艺术家主组件 │ │ ├── songs.vue # 艺术家歌曲组件 │ │ └── videos.vue # 艺术家视频组件 │ ├── Cloud.vue # 云盘组件 │ ├── Comment.vue # 评论组件 │ ├── DailySongs.vue # 每日推荐组件 │ ├── Discover # 发现音乐相关组件 │ │ ├── artists.vue # 发现音乐艺术家组件 │ │ ├── index.vue # 发现音乐主组件 │ │ ├── new.vue # 发现音乐新歌组件 │ │ ├── playlists.vue # 发现音乐歌单组件 │ │ └── toplists.vue # 发现音乐排行榜组件 │ ├── History.vue # 历史记录组件 │ ├── Home.vue # 主页组件 │ ├── Like # 我喜欢的相关组件 │ │ ├── albums.vue # 我喜欢的专辑组件 │ │ ├── artists.vue # 我喜欢的艺术家组件 │ │ ├── index.vue # 我喜欢的主组件 │ │ ├── playlists.vue # 我喜欢的歌单组件 │ │ └── videos.vue # 我喜欢的视频组件 │ ├── List # 列表相关组件 │ │ ├── album.vue # 专辑组件 │ │ └── playlist.vue # 歌单组件 │ │ └── dj.vue # 电台组件 │ ├── Local # 本地音乐相关组件 │ │ ├── albums.vue # 本地音乐专辑组件 │ │ ├── artists.vue # 本地音乐艺术家组件 │ │ ├── index.vue # 本地音乐主组件 │ │ └── songs.vue # 本地音乐歌曲组件 │ ├── Player.vue # 视频播放器组件 │ ├── Dj # 电台相关组件 │ │ └── index.vue # 电台主组件 │ │ └── type.vue # 电台分类组件 │ ├── Search # 搜索相关组件 │ │ ├── albums.vue # 搜索专辑组件 │ │ ├── artists.vue # 搜索艺术家组件 │   │   ├── index.vue # 搜索主组件 │   │   ├── playlists.vue # 搜索歌单组件 │   │   ├── songs.vue # 搜索歌曲组件 │   │   └── videos.vue # 搜索视频组件 │   │   └── djs.vue # 搜索电台组件 │   ├── Setting # 设置相关组件 │   │   └── index.vue # 设置主组件 │   ├── Song.vue │   ├── State │   │   ├── 403.vue │   │   ├── 404.vue │   │   └── 500.vue │   └── Test.vue └── vercel.json # Vercel 部署配置 ``` </details> ## ⭐ Star History [![Star History Chart](https://api.star-history.com/svg?repos=imsyy/SPlayer&type=Date)](https://star-history.com/#imsyy/SPlayer&Date)
🎉 一个简约的音乐播放器,支持逐字歌词,下载歌曲,展示评论区,音乐云盘及歌单管理,音乐频谱,移动端基础适配 | A minimalist music player
music,music-player,pinia,vite,vue,splayer,music-library,javascript,vue3,musicplayer
2023-01-06T15:05:33Z
2024-05-23T10:01:16Z
2024-04-26T02:02:25Z
2
46
274
4
291
663
null
AGPL-3.0
Vue
xiaoli1999/custom-avatar
master
## 定制头像🌈 ![预览](perview.png) ### 前言 在娱乐的同时弘扬中国传统节日文化! 大家定制了精美的头像,在使用过程中会被更多的人们看到,吸引大家都来定制自己专属的中国传统节日头像,潜移默化的加深人们对于传统节日的印象! ### 项目描述 该项目是基于vue3、typescript、Element UI、fabric.js的一款定制头像工具。 当前版本为2.0,在1.0(定制春节头像)上迭代。 推出定制中秋节、国庆节、春节等多风格头像定制, 内置诸多精美贴纸可供选择。 用户上传头像即可快速得出专属头像,支持保存、以海报的形式分享。开设头像墙区域,用户定制过的头像都会保留在头详墙上。 ### 特点 操作简单,用户可定制,灵活性高。 ### 地址 [github✈️ https://github.com/xiaoli1999/custom-avatar](https://github.com/xiaoli1999/custom-avatar) [gitee✈️ https://gitee.com/cui-zhe/custom-avatar](https://gitee.com/cui-zhe/custom-avatar) ### 预览 [主站✈️ https://www.xiaoli.vip/custom-avatar](https://www.xiaoli.vip/custom-avatar) [github pages✈️ https://xiaoli1999.github.io/custom-avatar](https://xiaoli1999.github.io/custom-avatar) ### 教程 1. 选择头像形状(微信为方形、qq、抖音等平台为圆形)。 2. 上传头像,(不支持动图)。 3. 选择头像框,贴纸可多选。 4. 完成上述步骤后,对效果图大小或位置不满意;可在画布区域微调,调整透明度。 5. 点击保存图片,分享给朋友。 ### 开源 目前代码已开源, 如果你喜欢这个项目或使用过它,请点个star⭐,谢谢🙏🙏🙏! 目前效果图属于个人定制,数量有限;希望有志同道合的设计师,提供一些头像框,小黎不胜感激🙏。这个项目有您的参与变的更有意义🤝。 联系方式~**QQ: 22708206** ### 文章链接 #### 2.0版本 [**掘金**](https://juejin.cn/post/7283018190594572328) [CSDN](https://blog.csdn.net/weixin_53673959/article/details/133343181) #### 1.0.版本 [**掘金**](https://juejin.cn/post/7189198252460212283) [CSDN](https://blog.csdn.net/weixin_53673959/article/details/128708172) ### 版本更新 * **v2.0.0(当前版本)** #### 仓库名称 - [x] 由 **custom-rabbitImage** 改为 **custom-avatar** #### 页面 - [x] 重构页面整体风格,调整为通用型风格 - [x] 兼容pc、移动端 - [x] 移动端头像墙采用瀑布流 #### 画布相关 - [x] 用户上传的原图做短边适配,保证不变形 - [x] 优化元素控件效果,增加删除控件 - [x] 优化绘制逻辑,减少无用运算。 #### 新增功能 - [x] 增加多主题选项(中秋节、国庆节、春节等,其他传统节日敬请期待) - [x] 增加贴纸效果,可多选、可删除 - [x] 增加快速切换头像框功能 - [x] 增加通知功能(xx用户在3分钟前定制了国庆头像) - [x] 增加分享海报功能 - [x] 增加头像墙功能,用户可预览他人定制的头像 #### 修复已知问题 - [x] 修复qq浏览器无法选择文件 - [x] 修复微信浏览器无法保存图片 * **v1.4.0** - [x] 解决保存图片模糊问题 * **v1.3.3** - [x] 调整PC版版本迭代 - [x] 调整效果图区域 - [x] 优化页面展示 * **v1.3.2** - [x] 压缩静态资源,优化网站加载速度 * **v1.3.1** - [x] 优化新年寄语-教程描述及展示 * **v1.3.0** - [x] 一大批新年效果图来袭~(设计师温言)🔥🔥🔥 * **v1.2.2** - [x] 新增版本迭代信息弹窗 * **v1.2.1** - [x] 优化透明度功能滑块区域(太靠右侧易误触) - [x] 优化页面交互 * **v1.2.0** - [x] 重构页面布局 - [x] 新增设置效果图透明度功能 - [x] 优化页面展示 * **v1.0.0** - [x] 初版 ### 流程图 ![流程图](./flow.png) ### 版权/协议 本项目采用 **MIT License**,请随意使用。若你喜欢或对你有所帮助,请点个⭐。 ### 兼容 兼容pc、移动端等 ### 计划 - 修复项目问题 - 根据用户意见、建议优化完善项目 ### FAQ 有任何意见或建议请提**issues**
快速定制中国传统节日头像,国庆国旗头像。customize avatars for traditional Chinese festivals such as National Day, Mid-Autumn Festival, and Spring Festival."
custom,vue3,custom-image,javascript,avatar,css,html,custom-avatar
2023-01-11T12:11:45Z
2023-11-15T07:19:49Z
null
1
1
116
2
41
298
null
MIT
Vue
elemaudio/elementary
main
<div align="center"> <img height="120px" src="https://www.elementary.audio/Lockup.svg" alt="Elementary Audio logo" /> <br /><br /> [![CI Status](https://github.com/elemaudio/elementary/actions/workflows/main.yml/badge.svg)](https://github.com/elemaudio/elementary/actions) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/elemaudio/elementary/blob/main/LICENSE.md) [![Discord Community](https://img.shields.io/discord/826071713426178078?label=Discord)](https://discord.gg/xSu9JjHwYc) [![npm installs](https://img.shields.io/npm/dt/%40elemaudio/core?label=npm%20installs&color=%23f472b6)](https://www.npmjs.com/package/@elemaudio/core) </div> --- [**Elementary**](https://elementary.audio) is a JavaScript library for digital audio signal processing. * **Declarative:** Elementary makes it simple to create interactive audio processes through functional, declarative programming. Describe your audio process as a function of your application state, and Elementary will efficiently update the underlying audio engine as necessary. * **Dynamic:** Most audio processing frameworks and tools facilitate building static processes. But what happens as your audio requirements change throughout the user journey? Elementary is designed to facilitate and adapt to the dynamic nature of modern audio applications. * **Portable:** By decoupling the JavaScript API from the underlying audio engine (the "what" from the "how"), Elementary enables writing portable applications. Whether the underlying engine is running in the browser, an audio plugin, or an embedded device, your JavaScript layer remains the same. ## Getting Started Every Elementary application starts with the [@elemaudio/core](https://www.elementary.audio/docs/packages/core) package ([npm](https://www.npmjs.com/package/@elemaudio/core), [source](./js/packages/core)), which provides the framework for defining your audio processes and a generic set of utilities for performing the graph rendering and reconciling steps. Next, because Elementary is designed to be used in a number of different environments, there are several different ways to integrate. If you're new to the project, we recommend studying the following workflows to get the feel of working in Elementary: * Use the [@elemaudio/web-renderer](https://www.elementary.audio/docs/packages/web-renderer) package ([npm](https://www.npmjs.com/package/@elemaudio/web-renderer), [source](./js/packages/web-renderer)) with your favorite frontend UI library to make an audio web application * Use the [@elemaudio/offline-renderer](https://www.elementary.audio/docs/packages/offline-renderer) package ([npm](https://www.npmjs.com/package/@elemaudio/offline-renderer), [source](./js/packages/offline-renderer)) with Node.js for static file processing Once you're ready to dive in, we suggest starting with one of these ideas: * Jump into the [online playground](https://www.elementary.audio/playground) for the quickest way of experimenting with sound * Make an audio effects plugin following the [SRVB plugin template](https://github.com/elemaudio/srvb) * Try the small [command line tool](https://github.com/elemaudio/elementary/tree/main/cli) here in this repository to explore an example native integration * Check out the [Native Integrations](https://www.elementary.audio/docs/guides/Native_Integrations) guide for embedding Elementary's C++ engine in your own native code * Read the [Custom Native Nodes](https://www.elementary.audio/docs/guides/Custom_Native_Nodes) guide for extending Elementary's built-in DSP library with your own low-level processors ## Documentation You can find the Elementary documentation [on the website](https://elementary.audio/), or if you like, you can jump straight into: * [Guides](https://elementary.audio/docs/guides/Making_Sound/) * [Tutorials](https://www.elementary.audio/docs/tutorials/distortion-saturation-wave-shaping) * [Project Showcase](https://www.elementary.audio/showcase) If you need help, join the community on the [Elementary Audio Discord](https://discord.gg/xSu9JjHwYc) and ask any questions you have! ## Releases Releases are made both here in GitHub and deployed to [npm](https://www.npmjs.com) following npm's semver conventions. Because your project may need to coordinate both the native C++ library and the corresponding JavaScript dependencies, it may be helpful to understand our release conventions. * Canary releases are always made first on the `develop` branch using git tags * Corresponding JavaScript packages are deployed to npm tagged `next` to indicate their status * After a brief validation period, canary releases are promoted to `main` via git merge * The corresponding JavaScript packages are then tagged `latest`, making them the default install candidates on npm * At this time a new GitHub Release is written to mark the update and document the changelog As a general rule of thumb, we recommend integrating Elementary via the `main` branch of this repo and the corresponding `latest` packages on npm. If you want to target the more bleeding edge, you can integrate via the git tags on the `develop` branch and the corresponding `next` packages on npm. ## Contributing We'd love to get you involved! Right now, the primary focus is to promote and grow the Elementary community. So if you want to help, consider: * Making an open source project with Elementary, like [this one](https://github.com/bgins/coincident-spectra) or [this one](https://github.com/teetow/elementary_grid) * Writing your own higher-level modules and sharing them on npm, [like this](https://github.com/nick-thompson/drumsynth/) * Writing your own custom native nodes to extend the engine and sharing them on GitHub If you're more interested in digging in under the hood, check out the [open issues](https://github.com/elemaudio/elementary/issues) to see where we need help right now. Note that while we're focusing on the community around Elementary, the immediate goals in this repository are ease of use, extensibility, and performance. We will likely be careful and slow to add new features, so if there's a particular feature you want to see here, please [open an issue](https://github.com/elemaudio/elementary/issues/new) to start a conversation around your proposal first. If you wish to become involved in the project beyond development, you could [become a sponsor](https://github.com/sponsors/nick-thompson). This form of assistance is deeply valued and instrumental in propelling the project forward. We are genuinely grateful for any support you choose to provide. ## License Elementary is [MIT licensed](./LICENSE.md).
Elementary is a JavaScript library for digital audio signal processing.
audio,dsp,functional,javascript
2023-01-09T14:11:28Z
2024-04-14T18:04:08Z
2024-02-14T13:19:27Z
16
15
187
6
22
282
null
MIT
C
jahidulislamzim/JavaScriptCodingChallenges
main
<img src='./images/logo.png' alt='JavaScript Coding Challenges jahidul islam zim' id='header'/> <h1 align="center" >JavaScript Coding Challenges </h1> <div align="center" > <a href="mailto:jahidulislamzim845@gmail.com"> <img src='https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white' alt='jahidul islam zim' /> </a> <a href="tel:+8801780115943"> <img src='https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white' alt='jahidul islam zim' /> </a> <a href="https://jahidulislamzim.netlify.app" target="_blank"> <img src='https://img.shields.io/badge/website-000000?style=for-the-badge&logo=About.me&logoColor=white' alt='jahidul islam zim' /> </a> <a href="https://www.facebook.com/jahidulislamzim43" target="_blank"> <img src='https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white' alt='jahidul islam zim' /> </a> <a href="https://www.linkedin.com/in/jahidulislamzim/" target="_blank"> <img src='https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white' alt='jahidul islam zim' /> </a> <a href="https://github.com/jahidulislamzim" target="_blank"> <img src='https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white' alt='jahidul islam zim' /> </a> </div> ##### 01. Creates a function that takes two numbers as arguments and return their sum. ```js function addition(a, b) { //Write Your solution Here }; console.log(addition(10, 20)); // 30 console.log(addition(30, 20)); // 50 console.log(addition(10, 90)); // 100 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function addition(a, b) { let add = a + b; return (add) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 02. Converts hours into seconds. ```js function howManySeconds(hours) { //Write Your solution Here }; console.log(howManySeconds(12)); // 43200 console.log(howManySeconds(8)); // 28800 console.log(howManySeconds(3)); // 10800 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function howManySeconds(hours) { let hoursToSeconds = (hours*3600); return(hoursToSeconds) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 03. Converts minutes into seconds. ```js function convert(minutes){ //Write Your solution Here }; console.log(convert(30)); // 1800 console.log(convert(10)); // 600 console.log(convert(20)); // 1200 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function convert(minutes) { let seconds = minutes*60; return (seconds) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 04. Calculates total points of a team from number of wins(3pts), draws(1pt), and losses(0pt). ```js function footballPoints(wins, draws, losses){ //Write Your solution Here }; console.log(footballPoints(4, 3, 1)); // 15 console.log(footballPoints(10, 5, 0)); // 35 console.log(footballPoints(11, 0, 9)); // 33 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function footballPoints(wins, draws, losses) { let points = (wins*3) + (draws*1) + (losses*0) return(points) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 05. Write functions to calculate the bitwise AND, bitwise OR and bitwise XOR of two numbers. ```js function bitwiseAND(n1, n2) { //Write Your solution Here }; function bitwiseOR(n1, n2) { //Write Your solution Here }; function bitwiseXOR(n1, n2) { //Write Your solution Here }; console.log(bitwiseAND(10, 20)); // 0 console.log(bitwiseOR(10, 20)); // 30 console.log(bitwiseXOR(10, 20)); // 30 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function bitwiseAND(n1, n2) { let answer = n1 & n2; return (answer); }; function bitwiseOR(n1, n2) { let answer = n1 | n2; return (answer); }; function bitwiseXOR(n1, n2) { let answer = n1 ^ n2; return (answer); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 06. Write Function to return first value of an array. ```js function getFirstValue(arr) { //Write Your solution Here }; console.log(getFirstValue(["Saab", "Volvo", "BMW"])); // Saab console.log(getFirstValue([3, 5, 1])); // 3 console.log(getFirstValue(['hello', 'world', 'welcome'])); // hello ``` <details><summary style="cursor:pointer">Solution</summary> ```js function getFirstValue(arr) { return arr[0]; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 07. Create a function that takes a number as an argument, increments the number by +1 and returns the result. ```js function addition(num){ //Write Your solution Here }; console.log(addition(5)); // 6 console.log(addition(100)); // 101 console.log(addition(99)); // 100 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function addition(num) { let numPlusOne = num + 1; return(numPlusOne) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 08. Given two numbers, return true if the sum of both numbers is less than 100. Otherwise return false. ```js function lessThan100(a, b){ //Write Your solution Here }; console.log(lessThan100(10, 20)); // true console.log(lessThan100(50, 60)); // false console.log(lessThan100(20, 50)); // true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function lessThan100(a, b) { if (a + b < 100) { return true; } else { return false; } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 09. Create a function that returns true when num1 is equal to num2; otherwise return false. ```js function isSameNum(num1, num2){ //Write Your solution Here }; console.log(isSameNum(30, 30)); // true console.log(isSameNum(20, 40)); // false console.log(isSameNum(50, 50)); // true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function isSameNum(num1, num2) { if (num1 === num2){ return true; } else { return false; } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 10. Create a function that takes a number (step) as an argument and returns the amount of matchsticks in that step. <div align="center"> <img src='./images/matchstick.png' alt='JavaScript Coding Challenges jahidul islam zim' id='header'/> </div> ```js function matchHouses(step){ //Write Your solution Here }; console.log(matchHouses(5)); // 26 console.log(matchHouses(0)); // 0 console.log(matchHouses(10)); // 51 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function matchHouses(step){ if (step > 0) { let matchSticks = ((step*6) - (step -1)); return(matchSticks) } else { let matchSticks = 0; return (matchSticks) } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 11. Write function to return the square of a number. ```js function squared(a){ //Write Your solution Here }; console.log(squared(6)); // 36 console.log(squared(9)); // 81 console.log(squared(4)); // 16 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function squared(a) { return (a*a); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 12. Write function to calculate Perimeter of Rectangles ```js function findPerimeter(height, width){ //Write Your solution Here }; console.log(findPerimeter(20, 50)); // 140 console.log(findPerimeter(80, 30)); // 220 console.log(findPerimeter(10, 40)); // 100 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function findPerimeter(height, width){ let perimeter = 2*(height + width); return (perimeter) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 13. Add up all the numbers from 1 to the number you passed to the function. ```js function addUp(num){ //Write Your solution Here }; console.log(addUp(10)); // 55 console.log(addUp(40)); // 820 console.log(addUp(15)); // 120 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function addUp(num) { let sum = 0; for (i = 0; i <= num; i++){ sum += i; } return(sum) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 14. Create a function that takes in three arguments (prob, prize, pay) and returns true if prob * prize > pay; otherwise return false. ```js function profitableGamble(prob, prize, pay){ //Write Your solution Here }; console.log(profitableGamble(2, 10, 20)); // false console.log(profitableGamble(5, 10, 40)); // true console.log(profitableGamble(6, 3, 30)); // false ``` <details><summary style="cursor:pointer">Solution</summary> ```js function profitableGamble(prob, prize, pay){ if (prob*prize > pay) { return (true) } else { return (false) } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 15. Takes an array of numbers, returns both the minimum and maximum numbers, in that order. ```js function minMax(arr){ //Write Your solution Here }; console.log(minMax([2, -1, 5])); // [ -1, 5 ] console.log(minMax([0, 5, 2])); // [ 0, 5 ] console.log(minMax([2, -5, -1])); // [ -5, 2 ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function minMax(arr){ arr.sort(function(a, b){return(a - b)}) return [arr[0], arr[arr.length - 1]] }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 16. Create a function that returns true if the first array can be nested inside the second. ###### arr1 can be nested inside arr2 if: ###### arr1's min is greater than arr2's min. ###### arr1's max is less than arr2's max. ```js function canNest(arr1, arr2){ //Write Your solution Here }; console.log(canNest([3, 1], [4, 0])); // true console.log(canNest([9, 9, 8], [8, 9])); // false console.log(canNest([1, 2, 3, 4], [0, 6])); // true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function canNest(arr1, arr2) { arr1.sort(function(a,b){return(a - b)}); arr2.sort(function(a,b){return(a - b)}); let arr1MinMax = [arr1[0], arr1[arr1.length -1]]; let arr2MinMax = [arr2[0], arr2[arr2.length -1]]; if (arr1MinMax[0] > arr2MinMax[0] && arr1MinMax[1] < arr2MinMax[1]){ return true } else{ return false } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 17. Create a function that calculates the number of different squares in an n * n square grid. <div align="center"> <img src='./images/squer-grid.png' alt='JavaScript Coding Challenges jahidul islam zim' id='header'/> </div> ```js function numberSquares(n){ //Write Your solution Here }; console.log(numberSquares(4)); // 30 console.log(numberSquares(5)); // 55 console.log(numberSquares(6)); // 91 ``` <details><summary style="cursor:pointer">Solution</summary> <div align="center"> <img src='./images/squer-grid-formula.png' alt='JavaScript Coding Challenges jahidul islam zim' id='header'/> </div> ```js function numberSquares(n){ let num = n*(2*n + 1)*(n + 1)/6 return (num) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 18. Your function will be passed two functions, f and g, that don't take any parameters. Your function has to call them, and return a string which indicates which function returned the larger number. ###### If f returns the larger number, return the string f. ###### If g returns the larger number, return the string g. ###### If the functions return the same number, return the string neither. ```js function whichIsLarger(f, g){ //Write Your solution Here }; console.log(whichIsLarger(() => 25, () => 15)); // f console.log(whichIsLarger(() => 25, () => 25)); // neither console.log(whichIsLarger(() => 25, () => 50)); // g ``` <details><summary style="cursor:pointer">Solution</summary> ```js function whichIsLarger(f, g){ if (f() > g()) { return ('f') } else if (g() > f()) { return ('g') } else if (f() === g()) { return ('neither') } }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 19. Christmas Eve is almost upon us, so naturally we need to prepare some milk and cookies for Santa! Create a function that accepts a Date object and returns true if it's Christmas Eve (December 24th) and false otherwise. Keep in mind JavaScript's Date month is 0 based, meaning December is the 11th month while January is 0. ```js function timeForMilkAndCookies(date){ //Write Your solution Here }; console.log(timeForMilkAndCookies(new Date(3000, 11, 24))); //true console.log(timeForMilkAndCookies(new Date(2013, 0, 23))); //false console.log(timeForMilkAndCookies(new Date(3000, 11, 24))); //true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function timeForMilkAndCookies(date){ return date.getMonth() === 11 && date.getDate() === 24; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 20. function that takes a two-digit number and determines if it's the largest of two possible digit swaps. ```js function largestSwap(num){ //Write Your solution Here }; console.log(largestSwap(14)); //false console.log(largestSwap(53)); //true console.log(largestSwap(-27)); //false ``` <details><summary style="cursor:pointer">Solution</summary> ```js function largestSwap(num){ let num1 = num + ""; let num2 = num1.split("").reverse().join(""); if (num1 >= num2) { return true; } if (num1 < num2) { return false; } }; function largestSwap(num) { let c = num.toString(); let a = []; let b = 0; for (let i = 0; i < c.length; i++) { a.push(c[c.length - 1 - i]); b += a[i]; } let d = parseInt(b); if (d > num) { return false; } else return true; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 21. function that takes two strings as arguments and returns the number of times the first string (the single character) is found in the second string. ```js function charCount(myChar, str){ //Write Your solution Here }; console.log(charCount("a", "largest")); //1 console.log(charCount("c", "Chamber of secrets")); // 2 console.log(charCount("b", "big fat bubble")); //4 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function charCount(myChar, str){ let a = 0; for (let i = 0; i < str.length; i++) { if (myChar.toLowerCase() === str.toLowerCase()[i]) { a += 1; } } return a }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 22. function that takes two parameters and repeats the string n number of times. ```js function repetition(txt, n){ //Write Your solution Here }; console.log(repetition('zim', 5)); //zimzimzimzimzim console.log(repetition('zoy', 2)); //zoyzoy console.log(repetition('akib', 7)); //akibakibakibakibakibakibakib ``` <details><summary style="cursor:pointer">Solution</summary> ```js function repetition(txt, n){ let reptxt = "" while (n > 0) { reptxt += txt n--; } return reptxt }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 23. function that takes an array of non-negative integers and strings and return a new array without the strings. ```js function filterArray(arr){ //Write Your solution Here }; console.log(filterArray([1, 'z', 4, 5, 'i', 9, 'm'])); //[ 1, 4, 5, 9 ] console.log(filterArray([8, 'z', 1, '8', 'i', 9, 'm'])); //[ 8, 1, 9 ] console.log(filterArray([7, '1', 'z', 0, 'i', 9, 'm'])); //[ 7, 0, 9 ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function filterArray(arr){ let filteredArray = arr.filter(item => typeof item === "number"); return filteredArray }; function filterArray(arr) { let filteredArr = []; for (let i = 0; i < arr.length; i++) { if ( typeof arr[i] !== "string") { filteredArr.push(arr[i]) } } return filteredArr }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 24. Write a function that take a string and write a regular expression inner function that returns the value that matches every red flag and blue flag in this string. ```js function matchFlag(str){ //Write Your solution Here }; console.log(matchFlag("yellow flag red flag blue flag green flag")); //[ 'red flag', 'blue flag' ] console.log(matchFlag("yellow flag green flag orange flag white flag")); //null console.log(matchFlag("yellow flag blue flag green flag")); //[ 'blue flag' ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function matchFlag(str){ let REGEXP = /red flag|blue flag/g; return str.match(REGEXP); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 25. Write a function that take a string and write a RegExp to find ellipsis: 3 (or more?) dots in a row in this string. ```js function matchEllipsis(str){ //Write Your solution Here }; console.log(matchEllipsis("Hello!... How goes?.....")); //[ '...', '.....' ] console.log(matchEllipsis("good morning!..... How goes?.")); // [ '.....' ] console.log(matchEllipsis("good night!.......... How goes?...")); // [ '..........', '...' ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function matchEllipsis(str){ let REGEXP = /\.{3,}/g; return str.match(REGEXP); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 26. Write a function that returns 0 if the input is 1, and returns 1 if the input is 0. Try completing this challenge without using any: ###### Conditionals ###### Ternary operators ###### Negations ###### Bit operators ```js function flip(y){ //Write Your solution Here }; console.log(flip(1)); // 0 console.log(flip(0)); // 1 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function flip(y){ let x = y - 1; return (Math.abs(x)) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 27. Create a function that takes a string and returns a string in which each character is repeated once. ```js function doubleChar(str){ //Write Your solution Here }; console.log(doubleChar('jahidul')); //jjaahhiidduull console.log(doubleChar('islam')); //iissllaamm console.log(doubleChar('zim')); //zziimm ``` <details><summary style="cursor:pointer">Solution</summary> ```js function doubleChar(str) { let doubleString = ''; for(let i=0; i<str.length; i++){ doubleString += str[i] + str[i] } return doubleString }; function doubleChar(str){ let array = str.split(""); let array2 = array.map( x => x.repeat(2)); let doubleString = array2.join(""); return doubleString }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 28. Write a function that takes a positive integer and return its factorial. ```js function factorial(num){ //Write Your solution Here }; console.log(factorial(5)); //120 console.log(factorial(10)); //3628800 console.log(factorial(8)); //40320 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function factorial(num) { let fact = 1; for (let i = 0; i<num ; i++){ fact *= (num-i); } return fact }; function factorial(num){ if (num < 0) return -1; else if (num == 0) return 1; else { return (num * factorial(num - 1)); } }; function factorial(num){ let result = num; if (num === 0 || num === 1) return 1; while (num > 1) { num--; result *= num; } return result; }; function factorial(num){ let fact = num; if (num === 0 || num === 1) return 1; for (let i = num - 1; i >= 1; i--) { fact *= i; } return fact; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 29. Take an array of integers (positive or negative or both) and return the sum of the absolute value of each element. ```js function getAbsSum(arr){ //Write Your solution Here }; console.log(getAbsSum([1, -4, 3, 8, 0])); // 16 console.log(getAbsSum([1, 3, 0, -8, 0])); // 12 console.log(getAbsSum([1, -4, -3, 8, 0])); //16 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function getAbsSum(arr){ let absSum = 0; for (var i = 0; i < arr.length; i++) { absSum += Math.abs(arr[i]); } return absSum; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 30. Write a function that take a string and write a REGEXP that matches any characters except letters, digits and spaces. ```js function matchAny(str){ //Write Your solution Here }; console.log(matchAny('Csxdzontains_underscore ')); //[ '_' ] console.log(matchAny('Csxdzontains_underscore $ * P')); //[ '_', '$', '*' ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function matchAny(str){ const REGEXP = /[^a-z0-9 ]/gi; return str.match(REGEXP) }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 31. Create a function that takes a string and returns the number (count) of vowels contained within it. ```js function countVowels(str){ //Write Your solution Here }; console.log(countVowels('Jahidul Islam zim')); // 6 console.log(countVowels('returns the number of vowels')); // 8 console.log(countVowels('JavaScript Coding Challenges')); // 8 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function countVowels(str){ let count = 0; let vowlStr = str.toLowerCase().match(/(a|e|i|o|u)/g); for (let i = 0; i < vowlStr.length; i++) { count += 1; } return count; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 32. Create a function that takes two vectors as arrays and checks if the two vectors are orthogonal or not. The return value is boolean. Two vectors a and b are orthogonal if their dot product is equal to zero. ```js function isOrthogonal(arr1, arr2){ //Write Your solution Here }; console.log(isOrthogonal([1, -2, 4], [2, 5, 2])); //true console.log(isOrthogonal([1, -2, 5], [2, 5, 2])); //false console.log(isOrthogonal([1, 2, 4], [-2, 5, -2])); //true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function isOrthogonal(arr1, arr2){ let ortho = 0; for (i = 0; i < arr1.length; i++){ ortho += arr1[i]*arr2[i] } if (ortho === 0) { return true } return false }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 33. Given an object of how many more pages each ink color can print, output the maximum number of pages the printer can print before any of the colors run out. ```js function inkLevels(inks){ //Write Your solution Here }; console.log(inkLevels({ cyan: 50, magenta: 12, yellow: 60 })); // 12 console.log(inkLevels({ cyan: 50, magenta: 120, yellow: 60 })); // 50 console.log(inkLevels({ cyan: 50, magenta: 12, yellow: 8 })); // 8 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function inkLevels(inks){ return Math.min(...Object.values(inks)); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 34. Create a function that takes a string and returns a new string with all vowels removed. ```js function removeVowels(str){ //Write Your solution Here }; console.log(removeVowels('Jahidul Islam Zim')); //Jhdl slm Zm console.log(removeVowels('a new string with all vowels')); // nw strng wth ll vwls console.log(removeVowels('Create a function')); //Crt fnctn ``` <details><summary style="cursor:pointer">Solution</summary> ```js function removeVowels(str){ let newArr = str.match(/[^aeiouAEIOU]/g); let newString = newArr.join(''); return newString }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 35. Create a function that takes an array of arrays with numbers. Return a new (single) array with the largest numbers of each. ```js function findLargestNums(arr){ //Write Your solution Here }; console.log(findLargestNums([[3,6], [10, 20], [-1, 7]])); //[ 6, 20, 7 ] console.log(findLargestNums([[8,6], [1, 0], [10, -7]])); //[ 8, 1, 10 ] console.log(findLargestNums([[3,34], [10, 22], [-1, -7]])); //[ 34, 22, -1 ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function findLargestNums(arr){ let newArr = [] for (let i = 0; i < arr.length; i++) { newArr.push(Math.max(...arr[i])); } return newArr }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 36. Given an array of scrabble tiles, create a function that outputs the maximum possible score a player can achieve by summing up the total number of points for all the tiles in their hand. Each hand contains 7 scrabble tiles. ```js function maximumScore(tileHand){ //Write Your solution Here }; console.log( maximumScore([ { tile: "N", score: 1 }, { tile: "K", score: 5 }, { tile: "Z", score: 10 }, ]) ); //16 console.log( maximumScore([ { tile: "N", score: 9 }, { tile: "K", score: 5 }, { tile: "Z", score: 40 }, ]) ); //54 console.log( maximumScore([ { tile: "N", score: 1 }, { tile: "K", score: 65 }, { tile: "Z", score: 10 }, ]) ); //76 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function maximumScore(tileHand){ let score = 0; for ( let i = 0; i < tileHand.length; i++) { score += tileHand[i].score; } return score; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 37. Assume a program only reads .js or .jsx files. Write a function that accepts a file path and returns true if it can read the file and false if it can't. ```js function isJS(path){ //Write Your solution Here }; console.log(isJS('file.jsx')); //true console.log(isJS('file.jsg')); //false console.log(isJS('file.js')); //true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function isJS(path){ let extension = path.match( /[^.]+$/g)[0] if(extension === 'js' || extension==='jsx'){ return true; } return false; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 38. A farmer is asking you to tell him how many legs can be counted among all his animals. The farmer breeds three species: ###### chickens = 2 legs ###### cows = 4 legs ###### goats = 4 legs ##### The farmer has counted his animals and he gives you a subtotal for each species. You have to implement a function that returns the total number of legs of all the animals. ```js function animals(chickens, cows, goats){ //Write Your solution Here }; console.log(animals(2, 3, 5)) // 36 console.log(animals(1, 2, 3)) // 22 console.log(animals(5, 2, 8)) // 50 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function animals(chickens, cows, goats){ return chickens*2 + cows*4 + goats*4; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 39.Create a function that returns the number of frames shown in a given number of minutes for a certain FPS. ###### FPS = Frames Per Second ```js function frames(minutes, fps){ //Write Your solution Here }; console.log(frames(1, 1)); //60 console.log(frames(10, 1)); //600 console.log(frames(10, 25)); //15000 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function frames(minutes, fps){ return minutes*60*fps; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 40.Create a function that takes two arguments. Both arguments are integers, a and b. Return true if one of them is 10 or if their sum is 10. ```js function makesTen(a, b){ //Write Your solution Here }; console.log(makesTen(1, 1)); //60 console.log(makesTen(10, 1)); //600 console.log(makesTen(10, 25)); //15000 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function makesTen(a, b){ if (a == 10 || b == 10) { return true; } else if (a + b == 10) { return true; } else { return false; }; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 41.Create a function that takes two strings as arguments and return either true or false depending on whether the total number of characters in the first string is equal to the total number of characters in the second string. ```js function comp(str1, str2){ //Write Your solution Here }; console.log(comp("AB", "CD")); //true console.log(comp("ABC", "DE")); //false console.log(comp("WE", "RT")); // true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function comp(str1, str2) { if (str1.length === str2.length) { return true; } return false; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 42.A vehicle needs 10 times the amount of fuel than the distance it travels. However, it must always carry a minimum of 100 fuel before setting off. Create a function which calculates the amount of fuel it needs, given the distance. ```js function calculateFuel(n){ //Write Your solution Here }; console.log(calculateFuel(15)); //150 console.log(calculateFuel(23.5)); //235 console.log(calculateFuel(3)); //100 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function calculateFuel(n){ let fuel = n * 10; if (fuel >= 100) { return fuel; }; return 100; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 43.Given an n-sided regular polygon n, return the total sum of internal angles (in degrees). n will always be greater than 2. ###### The formula (n - 2) x 180 gives the sum of all the measures of the angles of an n-sided polygon. ```js function sumPolygon(n){ //Write Your solution Here }; console.log(sumPolygon(3)); //180 console.log(sumPolygon(4)); //360 console.log(sumPolygon(6)); // 720 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function sumPolygon(n){ return (n - 2) * 180; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 44.Create a function that returns true if an integer is evenly divisible by 5, and false otherwise. ```js function divisibleByFive(n){ //Write Your solution Here }; console.log(divisibleByFive(5)); //true console.log(divisibleByFive(-55)); //false console.log(divisibleByFive(37)); //true ``` <details><summary style="cursor:pointer">Solution</summary> ```js function divisibleByFive(n){ if (n % 5 === 0) { return true; }; return false; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 45. Create a function that takes in an array of numbers and returns the sum of its cubes. ```js function sumOfCubes(nums){ //Write Your solution Here }; console.log(sumOfCubes([1, 2, 3, 4, 5])); //255 console.log(sumOfCubes([5, 2, 7, 4, 0])); //540 console.log(sumOfCubes([1, 6, 3, 9, 5])); //1098 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function sumOfCubes(nums){ var cubeSum = 0; for (i in nums) { cubeSum += nums[i] * nums[i] * nums[i]; }; return cubeSum;; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 46.A group of friends have decided to start a secret society. The name will be the first letter of each of their names, sorted in alphabetical order. Create a function that takes in an array of names and returns the name of the secret society. ```js function societyName(friends){ //Write Your solution Here }; console.log(societyName(['zim', 'zoy', 'shithil', 'akib'])); //zzsa console.log(societyName(['Rakib', 'Taskin', 'shomrat', 'Prionty'])); //RTsP console.log(societyName(['Ratul', 'Rakib', 'Ritu', 'Taj'])); //RRRT ``` <details><summary style="cursor:pointer">Solution</summary> ```js function societyName(friends){ let nameArr = friends.map((x) => x.split("")); let letterArr = ""; for (let i = 0; i < nameArr.length; i++) { letterArr += nameArr[i][0]; }; return letterArr; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 47. Create two functions: isPrefix(word, prefix-) and isSuffix(word, -suffix). ###### isPrefix should return true if it begins with the prefix argument. ###### isSuffix should return true if it ends with the suffix argument. ###### Otherwise return false. ```js function isPrefix(word, prefix) { //Write Your solution Here }; function isSuffix(word, suffix){ //Write Your solution Here }; console.log(isPrefix("automation", "auto-")); //true console.log(isPrefix("retrospect", "sub-")); //false console.log(isSuffix("arachnophobia", "-phobia")); //true console.log(isSuffix("vocation", "-logy")); //false ``` <details><summary style="cursor:pointer">Solution</summary> ```js function isPrefix(word, prefix) { return word.startsWith(prefix.slice(0, -1)); } function isSuffix(word, suffix) { return word.endsWith(suffix.slice(1)); } function isPrefix(word, prefix) { let prefixWord = prefix.slice(0, -1); let mainWord = ''; for(let i = 0; i < prefixWord.length; i++){ mainWord += word[i]; } if(prefixWord === mainWord){ return true; } return false; } function isSuffix(word, suffix) { let suffixWord = suffix.slice(1); let mainWord = ''; let newString = ''; for(let i = word.length - 1; i > suffixWord.length; i--){ mainWord += word[i]; } for (let i = mainWord.length - 1; i >= 0; i--) { newString += mainWord[i]; } if(suffixWord === newString){ return true; } return false; } ``` </details> --- **[⬆ Back to Top](#header)** ##### 48. Create a function that returns the number of hashes and pluses in a string. ```js function hashPlusCount(str){ //Write Your solution Here }; console.log(hashPlusCount("###+")); //[ 3, 1 ] console.log(hashPlusCount("##+++#")); //[ 3, 3 ] console.log(hashPlusCount("")); //[ 0, 0 ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function hashPlusCount(str){ let hash = (str.match(/#/g) || []).length; let plus = (str.match(/\+/g) || []).length; return [hash, plus]; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 49. Create a function that takes an array of 10 numbers (between 0 and 9) and returns a string of those numbers formatted as a phone number (e.g. (555) 555-5555). ```js function formatPhoneNumber(numbers){ //Write Your solution Here }; console.log(formatPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])); //(123) 456-7890 console.log(formatPhoneNumber([1, 2, 0, 4, 5, 3, 8, 1, 9, 0])); //(120) 453-8190 console.log(formatPhoneNumber([1, 7, 9, 4, 2, 6, 8, 8, 5, 0])); //(179) 426-8850 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function formatPhoneNumber(numbers) { numbers.splice(0, 0, "("); numbers.splice(4, 0, ")"); numbers.splice(5, 0, " "); numbers.splice(9, 0, "-"); let str = numbers.join(""); return str; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 50. Write a regular expression that matches only an even number. Numbers will be presented as strings. ```js function matchEven(str){ //Write Your solution Here }; console.log(matchEven("3458")); //8 console.log(matchEven("3517")); //Undefined console.log(matchEven("4902")); //2 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function matchEven(num){ let REGEXP = /[24680]$/; return num.match(REGEXP)?.[0]; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 51. Create a function that returns the index of the first vowel in a string. ```js function firstVowel(str){ //Write Your solution Here }; console.log(firstVowel("zimislam")); //1 console.log(firstVowel("akib")); //0 console.log(firstVowel("shomrat")); //2 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function firstVowel(str){ let regex = /[aeiou]/gi; return str.search(regex); }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 52. Create a function that removes all duplicate items from an array. ```js function removesDuplicateItems(arr){ //Write Your solution Here }; console.log(removesDuplicateItems(["A", "B", "A", "C", "D", "C"])); //[ 'A', 'B', 'C', 'D' ] console.log(removesDuplicateItems([1, 4, 2, 3, 2, 4, 3, 5])); //[ 1, 4, 2, 3, 5 ] console.log(removesDuplicateItems(["zim", "zoy", "zim", "akib", "shithil", "akib"]));//[ 'zim', 'zoy', 'akib', 'shithil' ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function removesDuplicateItems(arr) { const setArr = [...new Set(arr)]; return setArr; }; function removesDuplicateItems(arr) { let unique = arr.filter((element, index) => { return arr.indexOf(element) === index; }); return unique; }; function removesDuplicateItems(arr) { let unique = []; arr.forEach((c) => { if (!unique.includes(c)) { unique.push(c); }}); return unique; }; function removesDuplicateItems(arr){ let outputArray = []; let count = 0; let start = false; for (j = 0; j < arr.length; j++) { for (k = 0; k < outputArray.length; k++) { if (arr[j] == outputArray[k]) { start = true; } } count++; if (count == 1 && start == false) { outputArray.push(arr[j]); } start = false; count = 0; } return outputArray; }; function removesDuplicateItems(arr){ for (let i = 0; i < arr.length; i++) { for (let j = i + 1; j < arr.length; j++) { if (arr[i] === arr[j]) { for (let k = j; k < arr.length; k++) { arr[k] = arr[k + 1]; } arr.length--; j--; } } } return arr; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 53. Create a function that takes an array of numbers and returns a new array, sorted in ascending order (smallest to biggest). ```js function sortNumsAscending(arr){ //Write Your solution Here }; console.log(sortNumsAscending([2, 4, 6, 1, 9, 3, 5, 8, 7, 0])); //[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] console.log(sortNumsAscending([22, 40, 56, 11, 90])); //[ 11, 22, 40, 56, 90 ] console.log(sortNumsAscending([26, 45, 64, 19, 59, 31])); //[ 19, 26, 31, 45, 59, 64 ] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function sortNumsAscending(arr){ if ((arr === []) | (arr === null)) { return []; } return arr.sort(function (a, b){ return a - b; }); }; function sortNumsAscending(arr) { for (let i = 1; i < arr.length; i++) for (let j = 0; j < i; j++) if (arr[i] < arr[j]) { var x = arr[i]; arr[i] = arr[j]; arr[j] = x; } return arr; } ``` </details> --- **[⬆ Back to Top](#header)** ##### 54. Given a higher bound num, implement a function that returns an array with the sequence of numbers, after that every multiple of 4 has been amplified by 10. ```js function amplify(num) { //Write Your solution Here }; console.log(amplify(12)); //[1, 2, 3, 40, 5, 6, 7, 80, 9, 10, 11, 120] console.log(amplify(8)); //[1, 2, 3, 40, 5, 6, 7, 80 ] console.log(amplify(15)); //[1, 2, 3, 40, 5, 6, 7, 80, 9, 10, 11, 120,13, 14, 15] ``` <details><summary style="cursor:pointer">Solution</summary> ```js function amplify(num) { let arr = []; for ( let i = 1; i <= num; i++) { if (i % 4 === 0) { arr.push(i * 10); } else { arr.push(i); } } return arr; } ``` </details> --- **[⬆ Back to Top](#header)** ##### 55. Given an array of 10 numbers, return the maximum possible total made by summing just 5 of the 10 numbers. ```js function maxTotal(nums){ //Write Your solution Here }; console.log(maxTotal([1, 1, 0, 1, 3, 10, 10, 10, 10, 1])); //43 console.log(maxTotal([0, 0, 0, 0, 10, 0, 3, 0, 100])); // 113 console.log(maxTotal([1, 2, 3, 2, 5, 6, 9, 8, 9, 10])); //42 ``` <details><summary style="cursor:pointer">Solution</summary> ```js function maxTotal(nums){ let nums1 = nums.sort(function (a, b){return a-b}) let max = 0 for (i=5; i<nums1.length; i++){ max += nums1[i]; } return max; } ``` </details> --- **[⬆ Back to Top](#header)** ##### 56. Write a regular expression that matches a string if and only if it is a valid zip code. ###### Must only contain numbers (no non-digits allowed). ###### Must not contain any spaces. ###### Must not be greater than 5 digits in length. ```js function isValidZip(zip){ //Write Your solution Here }; console.log(isValidZip("393939")); //false console.log(isValidZip("59001")); //true console.log(isValidZip("853a7")); //false ``` <details><summary style="cursor:pointer">Solution</summary> ```js function isValidZip(zip) { const REXEX = /^\d{5}$/; return REXEX.test(zip); } ``` </details> --- **[⬆ Back to Top](#header)** ##### 57. Create a function that takes a number as an argument and returns the highest digit in that number. ```js function highestDigit(number){ //Write Your solution Here }; console.log(highestDigit(3456)); //6 console.log(highestDigit(21098)); //9 console.log(highestDigit(56123)); //6 ``` <details><summary style="cursor:pointer">Solution</summary> ```js const highestDigit = (number) => { let arr = (number.toString().split('')) return Math.max(...arr) } ``` </details> --- **[⬆ Back to Top](#header)** ##### 58. Create a function that takes a number as an argument and returns the highest digit in that number. ```js function highestDigit(number){ //Write Your solution Here }; console.log(highestDigit(3456)); //6 console.log(highestDigit(21098)); //9 console.log(highestDigit(56123)); //6 ``` <details><summary style="cursor:pointer">Solution</summary> ```js const highestDigit = (number) => { let arr = (number.toString().split('')) return Math.max(...arr) } ``` </details> --- **[⬆ Back to Top](#header)** ##### 59. Given an array of scrabble tiles, create a function that outputs the maximum possible score a player can achieve by summing up the total number of points for all the tiles in their hand. Each hand contains 7 scrabble tiles. ```js function maximumScore(titleHand){ //Write Your solution Here }; console.log(maximumScore([ { tile: "B", score: 2 }, { tile: "V", score: 4 }, { tile: "F", score: 4 }, { tile: "U", score: 1 }, { tile: "D", score: 2 }, { tile: "O", score: 1 }, { tile: "U", score: 1 } ])); // 15 console.log(maximumScore([ { tile: "N", score: 1 }, { tile: "K", score: 5 }, { tile: "Z", score: 10 }, { tile: "X", score: 8 }, { tile: "D", score: 2 }, { tile: "A", score: 1 }, { tile: "E", score: 1 } ])); // 28 ``` <details><summary style="cursor:pointer">Solution</summary> ```js const maximumScore = (titleHand) => { let maxScore = 0 for (i in titleHand){ maxScore += titleHand[i].score; } return maxScore; } ``` </details> --- **[⬆ Back to Top](#header)** ##### 60.Create a function that takes an array as an argument and returns true or false depending on whether the average of all elements in the array is a whole number or not. ```js const isAvgWhole = (arr) =>{ //Write Your solution Here }; console.log(isAvgWhole([1, 3])); // true console.log(isAvgWhole([1, 2, 3, 4])); // false console.log(isAvgWhole([1, 5, 6]));// true console.log(isAvgWhole([1, 1, 1]));// true console.log(isAvgWhole([9, 2, 2, 5]));// false ``` <details><summary style="cursor:pointer">Solution</summary> ```js const isAvgWhole = (arr) =>{ let sum = 0; for (i in arr){sum += arr[i]} if (sum%(arr.length)===0){return true} return false } ``` </details> --- **[⬆ Back to Top](#header)** ##### 61.Create a function that takes an array of strings and return an array, sorted from shortest to longest. ```js const sortByLength = (arr) =>{ //Write Your solution Here }; console.log(sortByLength(["a", "ccc", "dddd", "bb"])) //["a", "bb", "ccc", "dddd"] console.log(sortByLength(["apple", "pie", "shortcake"])) //["pie", "apple", "shortcake"] console.log(sortByLength(["may", "april", "september", "august"])) //["may", "april", "august", "september"] ``` <details><summary style="cursor:pointer">Solution</summary> ```js const sortByLength = (arr) => { return arr.sort(function (a,b){return a.length - b.length}) } const sortByLength = (arr) => { const n = arr.length; for (let i = 0; i < n - 1; i++) { for (let j = 0; j < n - i - 1; j++) { if (arr[j].length > arr[j + 1].length) { const temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } return arr; }; ``` </details> --- **[⬆ Back to Top](#header)** ##### 62. A value is omnipresent if it exists in every subarray inside the main array. Create a function that determines whether an input value is omnipresent for a given array.Create a function that takes an array of strings and return an array, sorted from shortest to longest. ```js const isOmnipresent = (arr, val) =>{ //Write Your solution Here }; console.log(isOmnipresent([[1, 1], [1, 3], [5, 1], [6, 1]], 1)); // true console.log(isOmnipresent([[1, 1], [1, 3], [5, 1], [6, 1]], 6)); // false console.log(isOmnipresent([[5], [5], [5], [6, 5]], 5)); // true console.log(isOmnipresent([[5], [5], [5], [6, 5]], 6)); //false ``` <details><summary style="cursor:pointer">Solution</summary> ```js const isOmnipresent = (arr, val) => { for (i in arr){ for (i in arr[i]){ return arr[i].includes(val) } } } ``` </details> --- **[⬆ Back to Top](#header)**
Hello JavaScript code newbie! In this repository I'm proposing you a series of coding challenges that will help you practice the basic language constructs and algorithms.
javascript,js-problem-solving,problem-solving,problemsolving,programming,coding-challenge,coding-challenges,js,coding,coding-test
2023-01-01T14:04:36Z
2023-08-04T13:30:31Z
null
1
0
51
0
48
226
null
null
null
boywithkeyboard/cheetah
dev
null
A framework for the modern web. (NO LONGER MAINTAINED)
cheetah,deno,javascript,typescript,framework,router,cloudflare,fast,cloudflare-workers,deno-deploy
2023-01-05T19:16:21Z
2023-11-12T14:58:32Z
2023-08-30T12:39:08Z
5
200
437
3
1
195
null
Apache-2.0
TypeScript
StarlaneStudios/cirql
main
<br> <div align="center"> <img src="https://raw.githubusercontent.com/StarlaneStudios/cirql/main/.github/branding/logo.png"> </div> <hr /> <br> <p align="center"> <a href="https://cirql.starlane.studio"> <img src="https://img.shields.io/badge/docs-available-de12b4"> </a> <a href="https://github.com/StarlaneStudios/cirql/blob/master/LICENSE"> <img src="https://img.shields.io/github/license/StarlaneStudios/cirql"> </a> <a href="https://discord.gg/exaQDX2"> <img src="https://img.shields.io/discord/414532188722298881"> </a> <img src="https://img.shields.io/bundlephobia/min/cirql"> <img src="https://img.shields.io/github/contributors/StarlaneStudios/cirql"> </p> Cirql (pronounced Circle) is a simple lightweight ORM and query builder for [SurrealDB](https://surrealdb.com/), providing fully type-safe queries and [Zod](https://github.com/colinhacks/zod) powered parsing & validation. Unlike most query builders, Cirql's flexible nature leaves you with complete control over your queries, while still providing powerful APIs to query your database in a concise manner. ## Features - 🔗 Connect to SurrealDB over stateful WebSockets or stateless HTTP requests - 📦 Support for query batching & transactions - ⚙️ Zod-powered schema validation of query results - 📝 Full TypeScript support with Zod schema inference - 💎 Write flexible queries using the Query Writer API - ✂️ Support for raw query strings and native Surreal functions - 🔥 Works both in browser and backend environments ## Notice Cirql is still in early developmental stages. While you can use it for production applications, it may still lack specific features and edge cases. Feel free to submit feature requests or pull requests to add additional functionality to Cirql. We do ask you to please read our [Contributor Guide](CONTRIBUTING.md). While we try to prevent making any significant API changes, we cannot guarantee this. ## Installation The first step to use Cirql is to install the package from npm, together with a supported version of zod. ``` npm install cirql zod ``` ## How to use You can [read our documentation](https://cirql.starlane.studio/) for information on how to use Cirql. ## Example The following query fetches up to 5 organisations that are enabled and have the given user as a member. The result is parsed and validated using the provided Zod schema. ```ts import { RecordSchema, select } from 'cirql'; import { z } from 'zod'; // Define your Zod schemas const Organisation = RecordSchema.extend({ name: z.string(), isEnabled: z.boolean(), createdAt: z.string() }); // Execute a select query const organisations = await cirql.execute({ query: select() .from('organisation') .with(Organisation) // Specify the schema .limit(5) .where({ isEnabled: true, members: any(userId) }) }); ``` Visit our [Basic Usage](https://cirql.starlane.studio/docs/guide/basic-usage) guide for more examples. ## Contributing We welcome any issues and PRs submitted to Cirql. Since we currently work on multiple other projects and our time is limited, we value any community help in supporting a rich future for Cirql. Before you open an issue or PR please read our [Contributor Guide](CONTRIBUTING.md). ### Requirements - [PNPM](https://pnpm.io/) (npm i -g pnpm) ### Roadmap You can find the roadmap of intended features [here](ROADMAP.md). ### Changelog The changelog of previous versions can be found [here](CHANGELOG.md). ### Live Development To run in live development mode, run `pnpm dev` in the project directory. This will start the Vite development server. ## Maintainers <a href="https://starlane.studio"> <img src="https://raw.githubusercontent.com/StarlaneStudios/cirql/main/.github/branding/starlane.png" height="64"> </a> Cirql is built and maintained by <a href="https://starlane.studio/">Starlane Studios</a> at no cost. If you would like to support our work feel free to [donate to us](https://paypal.me/ExodiusStudios) ⚡ ## License Cirql is licensed under [MIT](LICENSE) Copyright (c) 2023, Starlane Studios
🔧 A flexible SurrealDB ORM & query builder with Zod powered validation 🏋️‍♂️
browser,javascript,node,sql,surql,surrealdb,surrealql,typescript,builder,orm
2023-01-10T14:38:15Z
2023-10-31T09:50:19Z
null
7
3
237
6
6
181
null
MIT
TypeScript
drshahizan/learn-php
main
<a href="https://github.com/drshahizan/learn-php/stargazers"><img src="https://img.shields.io/github/stars/drshahizan/learn-php" alt="Stars Badge"/></a> <a href="https://github.com/drshahizan/learn-php/network/members"><img src="https://img.shields.io/github/forks/drshahizan/learn-php" alt="Forks Badge"/></a> <a href="https://github.com/drshahizan/learn-php/pulls"><img src="https://img.shields.io/github/issues-pr/drshahizan/learn-php" alt="Pull Requests Badge"/></a> <a href="https://github.com/drshahizan/learn-php/issues"><img src="https://img.shields.io/github/issues/drshahizan/learn-php" alt="Issues Badge"/></a> <a href="https://github.com/drshahizan/learn-php/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/drshahizan/learn-php?color=2b9348"></a> ![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fdrshahizan%2Flearn-php&labelColor=%23d9e3f0&countColor=%23697689&style=flat) # SCSV1223 - WEB PROGRAMMING ![Introduction to web programming](/images/webdev-programming.png) > Sketchnote by [Tomomi Imura](https://twitter.com/girlie_mac) ### Contents: - [Student Information](./materials/others/student-info.md) - [Code Samples](/materials/readme.md) - Useful Links - [Introduction to Web Programming](/materials/others/intro-wp.md) - [Visual Studio Code](/materials/others/vscode-intro.md) - [Code Quality Guide](/materials/others/intro-wp.md#code-quality-guide) - [HTML](/materials/html/readme.md#html) - [CSS](./materials/css/readme.md) - [JavaScript](./materials/javascript/readme.md) - [Bootstrap](./materials/bootstrap/readme.md) - [PHP](./materials/php/readme.md) - [Labs](./lab) ## Synopsis This course is designed to introduce students the fundamental of knowledge, technologies and components for web application developments. The basic topics includes the standard HTML for content creation, CSS for content presentation, JavaScript for client-side logics, PHP for server-side logics and MySQL for data processing. At the end of the course, the students should be able to apply the web base technologies and then implement it all in the creating functional data-centric online system project. ## 🔥 Important things 1. [Lecture Notes](https://drive.google.com/drive/folders/10Ukq2jzZMe0N4mmcTJoBmrNWDQiEifry?usp=sharing) 2. [Student Information](./materials/student-info.md) 3. [Buku: Pengaturcaraan Web Hypertext Preprocessor (PHP)](https://shopee.com.my/Pengaturcaraan-Web-Hypertext-Preprocessor-(PHP)-i.86546040.11086443454?sp_atk=22b16647-afe4-452a-9444-2c4f017c7dab&xptdk=22b16647-afe4-452a-9444-2c4f017c7dab) 4. [Free Web Development Books](https://github.com/NedyUdombat/Free-Web-Development-eBooks) 9. [Student Portfolio Showcase](https://drshahizan.github.io/scsv1223.html) #### Module | No | Module | Description | | :-----: | ------ | ------ | | 1 | [Introduction to Web Programming](/materials/others/intro-wp.md) | Web programming is the process of creating web pages and web-based applications using a variety of programming languages and technologies. To get started with web programming, one should learn HTML, CSS, and JavaScript, which are the core technologies used for creating web pages and user interfaces. Bootstrap is a popular framework that can simplify the process of creating responsive and mobile-friendly web pages. PHP is a server-side scripting language used for creating dynamic web pages and web-based applications. By learning these technologies, one can create attractive and interactive web content that is compatible with a wide range of devices and browsers. | | 2 | [Visual Studio Code](/materials/others/vscode-intro.md) | Visual Studio Code is a popular source code editor developed by Microsoft. It is free, open-source, and available for Windows, Mac, and Linux. Visual Studio Code supports a wide range of programming languages and provides features such as code highlighting, autocomplete, debugging, and source control integration. It also supports extensions that can add functionality, such as linters, formatters, and code snippets. With its user-friendly interface and robust set of features, Visual Studio Code has become a favorite among developers for writing, testing, and debugging code.| | 3 | [Hypertext Markup Language (HTML)](/materials/html/readme.md#hypertext-markup-language-html) | HTML is a markup language used for creating web pages and other web-based content. It uses tags and codes to structure and format content, such as headings, paragraphs, images, and links. HTML also allows for the creation of forms, which enable user interaction with web pages through input fields, buttons, and other elements. It is a fundamental technology for creating web pages and provides a standardized system for defining the structure and formatting of content. | | 4 | [Cascading Style Sheets (CSS)](/materials/css) | CSS is a stylesheet language used for describing the presentation of web pages and other web-based content. It allows content creators to control the layout, colors, fonts, and other visual elements of a web page, separate from the HTML markup. CSS works by applying rules to HTML elements, which define how they should be displayed. These rules can be applied to individual elements, groups of elements, or the entire page. CSS also supports the use of media queries, which allow for the creation of responsive designs that adapt to different device sizes and screen orientations. | | 5 | [JavaScript](./materials/javascript/readme.md) | JavaScript is a scripting language used primarily for creating interactive web pages and web-based applications. It is a client-side language that runs directly in a web browser and can be used to manipulate the content and behavior of web pages in real-time. JavaScript can be used to create animations, validate user input, fetch data from servers, and much more. It is a powerful language with a large and active community, and is commonly used alongside HTML and CSS to create dynamic and engaging web content. | | 6 | [Bootstrap](./materials/bootstrap/readme.md) | Bootstrap is a popular open-source framework used for creating responsive and mobile-first web pages and applications. It provides pre-designed templates, CSS styles, and JavaScript plugins that make it easy for developers to create visually appealing and functional websites. Bootstrap uses a grid system to enable the creation of flexible layouts that adapt to different device sizes and screen orientations. It also provides a variety of UI components, such as forms, buttons, navigation menus, and modals, that can be easily customized and integrated into web projects. | | 7 | [Hypertext Preprocessor (PHP)](./materials/php/readme.md) | PHP is a server-side scripting language used primarily for web development. It is a popular language for creating dynamic web pages and web-based applications, as it can interact with databases, handle form data, and perform other server-side tasks. PHP code is executed on the server before the web page is sent to the client's browser, allowing for the creation of complex and dynamic web content. PHP also has a large and active community that has developed many frameworks and libraries to simplify web development tasks. | ## Lab | Lab | Topic | Files | | :-----: | ----- | :------: | | 1| Hypertext Markup Language |<a href="./materials/html/exercise.md" ><img src="./images/html.png" width="36px" height="36px" ></a> | | 2 | Cascading Style Sheets |<a href="./materials/css/exercise.md" ><img src="./images/css.png" width="36px" height="36px" ></a> | | 3 | JavaScript |<a href="./materials/javascript/exercise.md" ><img src="./images/javascript.svg" width="24px" height="24px" ></a> | | 4 | Bootstrap |<a href="./materials/bootstrap/exercise.md" ><img src="./images/bootstrap.png" width="24px" height="24px" ></a> | | 5 | Hypertext Preprocessor |<a href="./materials/php/exercise.md" ><img src="./images/php.svg" width="24px" height="24px" ></a> | ## Project | Project | Topic | Files | | :-----: | ----- | :------: | | 1 | Student Portfolio Showcase (HTML) |<a href="./project/1-portfolio" ><img src="./images/html.png" width="36px" height="36px" ></a> | | 2 | Student Portfolio Showcase (Bootstrap) |<a href="./project/2-bootstrap/" ><img src="./images/bootstrap.png" width="24px" height="24px" ></a> | | 3 | Web Responsive using Bootstrap |<a href="./project/3-web" ><img src="./images/bootstrap.png" width="24px" height="24px" ></a> | | 4 | Final Project using PHP |<a href="./project/4-project" ><img src="./images/php.svg" width="24px" height="24px" ></a> | ## Tools Diagrams are visual representations of information or data that help convey complex concepts, processes or systems in a clear and concise manner. Flowcharts are diagrams that use shapes and arrows to illustrate the steps in a process or algorithm [**[More info...]**](./materials/tools.md). | No | Tools | File | | :-----: | ------ | :-----: | | 1 | Figma | <a href="https://github.com/drshahizan/software-engineering/blob/main/materials/figma.md" ><img src="./images/figma.svg" width="24px" height="24px" ></a> | | 2 | Draw.io| <a href="https://github.com/drshahizan/software-engineering/blob/main/materials/uml/drawio/1-draw-io.md" ><img src="./images/drawio.svg" width="24px" height="24px" ></a> | | 3 | Github Pages| <a href="https://github.com/drshahizan/learn-github/blob/main/materials/pages.md" ><img src="./images/github.svg" width="24px" height="24px" ></a> | | 4 | Behance| <a href="https://github.com/drshahizan/software-engineering/blob/main/materials/behance.md" ><img src="./images/behance.svg" width="24px" height="24px" ></a> | | 5 | Visual Studio Code| <a href="https://code.visualstudio.com/" ><img src="./images/vsc.svg" width="24px" height="24px" ></a> | | 6 | Bootstrap Studio| <a href="https://bootstrapstudio.io/" ><img src="./images/bootstrap-studio.png" width="24px" height="24px" ></a> | | 7 | Carbon| <a href="https://carbon.now.sh/" ><img src="./images/carbon.svg" width="24px" height="24px" ></a> | ## 📖 Extra Notes | No | Topic | Note | MCQ | Answer | :-----: | ----- | :------: | :------: | :------: | | 1 | JS Fundamentals | <a href="./materials/notes/n1.md"><img src="./images/javascript.svg" width="24px" height="24px"></a> | | | | | MCQ: Set A | | <a href="./materials/notes/n1aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n1aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n1bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n1ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 2 | JS DOM | <a href="./materials/notes/n2.md"><img src="./images/javascript.svg" width="24px" height="24px"></a> | | | MCQ: Set A | | <a href="./materials/notes/n2aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n2aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n2bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n2ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 3 | JS Event & JS Form Validation | <a href="./materials/notes/n3.md"><img src="./images/javascript.svg" width="24px" height="24px"></a> | | | MCQ: Set A | | <a href="./materials/notes/n3aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n3aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n3bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n3ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 4 | PHP Fundamentals | <a href="./materials/notes/n4.md"><img src="./images/php.svg" width="24px" height="24px"></a> | | | MCQ: Set A | | <a href="./materials/notes/n4aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n4aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n4bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n4ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 5 | PHP: MySQL and CRUD | <a href="./materials/notes/n5.md"><img src="./images/php.svg" width="24px" height="24px"></a> | | | MCQ: Set A | | <a href="./materials/notes/n5aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n5aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n5bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n5ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 6 | PHP: Form, Session & Cookies | <a href="./materials/notes/n6.md"><img src="./images/php.svg" width="24px" height="24px"></a> | | | MCQ: Set A | | <a href="./materials/notes/n6aq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n6aa.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | | MCQ: Set B | | <a href="./materials/notes/n6bq.md"><img src="./images/question.svg" width="24px" height="24px"></a> | <a href="./materials/notes/n6ba.md"><img src="./images/answer.png" width="24px" height="24px"></a> | | 7 | Final Exam | <a href="./materials/notes/contoh/readme.md"><img src="./images/php.svg" width="24px" height="24px"></a> | <a href="./materials/notes/contoh/readme.md"><img src="./images/question.svg" width="24px" height="24px"></a> | ## Contribution 🛠️ Please create an [Issue](https://github.com/drshahizan/learn-php/issues) for any improvements, suggestions or errors in the content. You can also contact me using [Linkedin](https://www.linkedin.com/in/drshahizan/) for any other queries or feedback. [![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fdrshahizan&labelColor=%23697689&countColor=%23555555&style=plastic)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fdrshahizan) ![](https://hit.yhype.me/github/profile?user_id=81284918)
This course is designed to introduce students the fundamental of knowledge, technologies and components for web application developments. The basic topics includes the standard HTML for content creation, CSS for content presentation, JavaScript for client-side logics, PHP for server-side logics and MySQL for data processing.
css,html,javascript,php,web-development
2023-01-14T05:03:00Z
2024-03-24T13:57:13Z
null
109
24
9,321
0
180
179
null
null
JavaScript
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card