This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Set the API key | |
| source ~/env.sh | |
| endpoint="https://api.openai.com/v1/completions" | |
| max_tokens=${2:-50} | |
| prompt=$1 | |
| temperature=0.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const BLOG_POSTS_URL = 'https://jsonplaceholder.typicode.com/posts'; | |
| const FETCH_TIMEOUT = 3000; | |
| const FETCH_INTERVAL = 4000; | |
| const TIMEOUT_ERROR_MESSAGE = 'Request timed out'; | |
| const controller = new AbortController() | |
| const getPosts = (signal) => fetch(BLOG_POSTS_URL, { | |
| signal | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const str = (greet) => console.log(greet); | |
| const id = "User1"; | |
| const obj = {}; | |
| const obj1 = {}; | |
| const logData = (...props) => { | |
| console.log(...props); | |
| props.forEach((item, index) => { | |
| if(typeof item === 'function') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(val) { | |
| this.val = val; | |
| this.left = undefined; | |
| this.right = undefined; | |
| this.parent = undefined; | |
| } | |
| } | |
| class BST { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require("http"), | |
| url = require("url"), | |
| path = require("path"), | |
| fs = require("fs") | |
| port = process.argv[2] || 8888; | |
| http.createServer(function(request, response) { | |
| var uri = url.parse(request.url).pathname | |
| , filename = path.join(process.cwd(), uri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function add_custom_sizes() { | |
| add_image_size( 'xlarge-square-thumb' , 500 , 500 , true ); | |
| add_image_size( 'large-square-thumb' , 340 , 340 , true ); | |
| add_image_size( 'medium-square-thumb' , 150 , 150 , true ); | |
| add_image_size( 'small-square-thumb' , 80 , 80 , true ); | |
| add_image_size( 'large-landscape-thumb' , 280, 210 , true); | |
| add_image_size( 'medium-landscape-thumb' , 160, 120 , true); | |
| add_image_size( 'small-landscape-thumb' , 100, 75 , true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function change_post_label() { | |
| global $menu; | |
| global $submenu; | |
| $menu[5][0] = 'News'; | |
| $submenu['edit.php'][5][0] = 'News'; | |
| $submenu['edit.php'][10][0] = 'Add News'; | |
| $submenu['edit.php'][16][0] = 'News Tags'; | |
| echo ''; | |
| } | |
| function change_post_object() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function add_custom_sizes() { | |
| add_image_size( 'thumb-16-9', 480, 273, true ); | |
| add_image_size( 'thumb-3-2', 480, 320, true ); | |
| add_image_size( 'thumb-1-1', 480, 480, true ); | |
| } | |
| add_action('after_setup_theme','add_custom_sizes'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Custom Contnet & Excerpt Length | |
| */ | |
| function excerpt($limit) { | |
| $excerpt = explode(' ', get_the_excerpt(), $limit); | |
| if (count($excerpt)>=$limit) { | |
| array_pop($excerpt); | |
| $excerpt = implode(" ",$excerpt).'...'; | |
| } else { | |
| $excerpt = implode(" ",$excerpt); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add a new logo to the login page | |
| function login_logo() { ?> | |
| <style type="text/css"> | |
| .login #login h1 a { | |
| background-image: url( '<?php bloginfo('template_url') ?>/img/logo.png' ); | |
| background-size: 300px auto; | |
| height: 50px; | |
| filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( | |
| src='<?php bloginfo('template_url') ?>/img/logo.png', | |
| sizingMethod='scale'); |
NewerOlder