#basic
Commonly used operators in programming
Arithmetic Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (Remainder)
++ Increment
Assignment Operators:
= Assignment
+= Addition assignment
-= Subtraction assignment
*= Multiplication assignment
/= Division assignment
%= Modulus assignment
Comparison Operators:
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
Logical Operators:
&& Logical AND
|| Logical OR
! Logical NOT
Conditional (Ternary) Operator:
? Conditional expression
Delimiters:
() Parentheses
{} curly brackets
[] square brackets
<> Angle brackets
Comments:
// Single-line comment
/* */ Multi-line comment
Commonly used operators in programming
Arithmetic Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (Remainder)
++ Increment
-- DecrementAssignment Operators:
= Assignment
+= Addition assignment
-= Subtraction assignment
*= Multiplication assignment
/= Division assignment
%= Modulus assignment
Comparison Operators:
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
Logical Operators:
&& Logical AND
|| Logical OR
! Logical NOT
Conditional (Ternary) Operator:
? Conditional expression
Delimiters:
() Parentheses
{} curly brackets
[] square brackets
<> Angle brackets
Comments:
// Single-line comment
/* */ Multi-line comment
❤1👍1
#php #ci4
Example code to validate rules for form submission in Codeigniter
$validation = \Config\Services::validation();
// Set the validation rules
$validation->setRules([
'username' => 'required|min_length[5]',
'email' => 'required|valid_email',
'password' => 'required|min_length[8]',
]);
// Run the validation
if (!$validation->withRequest($this->request)->run()) {
// Validation failed, redirect back with errors
return redirect()->back()->withInput()->with('errors', $validation->getErrors());
}
Example code to validate rules for form submission in Codeigniter
$validation = \Config\Services::validation();
// Set the validation rules
$validation->setRules([
'username' => 'required|min_length[5]',
'email' => 'required|valid_email',
'password' => 'required|min_length[8]',
]);
// Run the validation
if (!$validation->withRequest($this->request)->run()) {
// Validation failed, redirect back with errors
return redirect()->back()->withInput()->with('errors', $validation->getErrors());
}
#bestPractice #php #js #py
Join an array into String in (PHP, JS, PY)
Bad practice:
//python
print("a" + " " + "b)
//php
echo "a"." ".b";
Best Practice:
// js
console.log(["a", "b"].join(" "));
//python
print(" ".join(["a", "b"])
//php
echo implode(" ", ["a", "b"]);
Join an array into String in (PHP, JS, PY)
Bad practice:
//python
print("a" + " " + "b)
//php
echo "a"." ".b";
Best Practice:
// js
console.log(["a", "b"].join(" "));
//python
print(" ".join(["a", "b"])
//php
echo implode(" ", ["a", "b"]);
#js
Instant Execute Function in js
// Normally:
(function() {
// Code to be executed immediately
})();
//Best Way Its called arrow function:
(() => {
// Code to be executed immediately
})();
Instant Execute Function in js
// Normally:
(function() {
// Code to be executed immediately
})();
//Best Way Its called arrow function:
(() => {
// Code to be executed immediately
})();
👏2
#bestPractice #js
How to prevent
let user = { };
Noob coders:
if(user && user.name){
console.log(user.name);
}else{
console.log("No name found in user object")
}
Pro coders:
console.log(user?.name ?? "No name found in user Object")
Pro tips by Biswa
How to prevent
Cannot read properties of undefined using ? operatorlet user = { };
Noob coders:
if(user && user.name){
console.log(user.name);
}else{
console.log("No name found in user object")
}
Pro coders:
console.log(user?.name ?? "No name found in user Object")
Pro tips by Biswa
👍3😁2
#ci4 #ajax
How to enable csrf protection in ajax request in Ci 4
// Get csrf token from csrf field
var csrfToken = '<?= csrf_token() ?>';
// Make an AJAX request
$.ajax({
url: 'your_ajax_endpoint',
type: 'POST',
data: {
csrf_test_name: csrfToken, // Include the CSRF token in the request payload
// Other data parameters
},
success: function(response) {
// Handle the response
},
error: function(xhr, status, error) {
// Handle the error
}
});
Ci 4 controller:
$csrfToken = $this->request->getVar('csrf_test_name');
if (!csrf_check($csrfToken)) {
// CSRF verification failed, handle the error
return $this->response->setStatusCode(403)->setBody('Invalid CSRF token');
}
How to enable csrf protection in ajax request in Ci 4
// Get csrf token from csrf field
var csrfToken = '<?= csrf_token() ?>';
// Make an AJAX request
$.ajax({
url: 'your_ajax_endpoint',
type: 'POST',
data: {
csrf_test_name: csrfToken, // Include the CSRF token in the request payload
// Other data parameters
},
success: function(response) {
// Handle the response
},
error: function(xhr, status, error) {
// Handle the error
}
});
Ci 4 controller:
$csrfToken = $this->request->getVar('csrf_test_name');
if (!csrf_check($csrfToken)) {
// CSRF verification failed, handle the error
return $this->response->setStatusCode(403)->setBody('Invalid CSRF token');
}
#ci4 #framework
How to check header property in ci 4
$headerValue = $this->request->header('Header-Name');
// Verify
($this->request->hasHeader('Header-Name'))
How to check header property in ci 4
$headerValue = $this->request->header('Header-Name');
// Verify
($this->request->hasHeader('Header-Name'))
👍1K
#py
Convert a string into dict in Py
Convert a string into dict in Py
def strDict(string):
result = {}
pairs = string.split(";")
for pair in pairs:
if "=" in pair:
split_pair = pair.split("=", 1)
if len(split_pair) == 2:
key, value = split_pair
result[key.strip()] = value.strip()
return result#py
Divide a string into parts in Py
Divide a string into parts in Py
def divide_string(string, parts=4):
if len(string) % parts == 0:
part_length = len(string) // parts
return [string[i:i+part_length] for i in range(0, len(string), part_length)]
else:
return None#ci4
How to make REST API using Ci 4
create a controller:
How to make REST API using Ci 4
create a controller:
// Check CSRF validation
if (!$this->request->isAJAX() || !$this->request->isValidCSRF()) {
return $this->response->setStatusCode(403)->setJSON(['message' => 'Forbidden', 'code' => 403]);
}
// Set the content type to JSON
$this->response->setContentType('application/json');
// set api resonse
// Example response
return $this->response->setJSON(['message' => 'Success']);👎1
Protect your site from bots using FingerPrintJs
https://fingerprintjs.github.io/BotD/main/
Example usage:
Bonus tips: Put the code in head tag
Use Load event
addEvenListener("load"... Bot detection will trigger when document loaded
https://fingerprintjs.github.io/BotD/main/
Example usage:
const botdPromise = import('https://openfpcdn.io/botd/v1').then((Botd) => Botd.load()) // Get detection results when you need them. botdPromise .then((botd) => botd.detect()) .then((result) => console.log(result)) .catch((error) => console.error(error))Bonus tips: Put the code in head tag
Use Load event
addEvenListener("load"... Bot detection will trigger when document loaded
👍2❤1
How to merge 2 or many json dict into One in (Python, PHP, JS)
#js
Usage: Use "var" keyword to re assign the variable and use spread method to merge "...json object "
#php
Usage: array_merge used to merge arrays into one array and we need use json_decode and json_encode to make a json obj
#py
Best way to merge in python is using unpacking operator
#js
var b = { success:true }
var c = { message: "something", ...b }
console.log(c)Usage: Use "var" keyword to re assign the variable and use spread method to merge "...json object "
#php
$b = [ "success"=> true ];
$c = ["biswa":"string"];
array_merge($b, $c)
Usage: array_merge used to merge arrays into one array and we need use json_decode and json_encode to make a json obj
#py
Best way to merge in python is using unpacking operator
**dict_name here is example:b = { "success":True }
c = { "hell":None}
print({**b, **c})😱7😢5🤮4💩4😁3🤬3👎2🤔2👍1🔥1🤯1
Good Looking Toast UI
Usage:
Download Source:
https://github.com/abdmmar/wc-toast/archive/refs/heads/main.zip
Demo:
https://www.cssscript.com/demo/notification-wc-toast
Usage:
import { toast } from 'https://cdn.skypack.dev/wc-toast';
// Error message
toast.error('Authentication failed');
// Success message
toast.success('Authentication success');
Download Source:
https://github.com/abdmmar/wc-toast/archive/refs/heads/main.zip
Demo:
https://www.cssscript.com/demo/notification-wc-toast
🔥4❤1
Forwarded from Off
spotify.py
5.3 KB
Spotify Account Generator
Response Improved
Android API
~ Coded By Biswa xD
Response Improved
Android API
~ Coded By Biswa xD
#python
Basic Threading Example - Run your code in parallel
Usage:
target= which function do u want to run on thread
args= the required params of targeted function
Basic Threading Example - Run your code in parallel
import threading
def sum(x, y):
result = x + y
print(f"The sum of {x} and {y} is {result}")
# Number of iterations num_iterations = 50
# Loop to create and start threads
for i in range(num_iterations):
thread = threading.Thread(target=sum, args=(3, 5))
# Start the thread
thread.start()
# Wait for all threads to finish
thread.join()
print("Program completed.")Usage:
target= which function do u want to run on thread
args= the required params of targeted function
👍7❤1
Free SMM Bot coming with rate-limit :D
...wait and see views of this post
...wait and see views of this post
❤11🔥2
Make Your Own AI GPT with LLAMA 2 Model
Features:
- Open source
- Unlimited use
- Works offline
- No need api key
- 7 Billion Chat
Requirement:
Python 3.10 +
wget
Source: https://github.com/h2oai/h2ogpt
Features:
- Open source
- Unlimited use
- Works offline
- No need api key
- 7 Billion Chat
Requirement:
Python 3.10 +
wget
Source: https://github.com/h2oai/h2ogpt
👍5
ChatGPT 4 + IMAGE GENERATOR API
-> Unlimited Usage
-> Unlimited Image Generation
-> Rest API
-> FREE OFCOURSE
WILL DROP HERE
10+ ❤️ reaction required :D
-> Unlimited Usage
-> Unlimited Image Generation
-> Rest API
-> FREE OFCOURSE
WILL DROP HERE
10+ ❤️ reaction required :D
❤67👎3👍2🔥2
𝙐𝙣𝙧𝙚𝙖𝙡 𝘾𝙤𝙙𝙚𝙧
ChatGPT 4 + IMAGE GENERATOR API -> Unlimited Usage -> Unlimited Image Generation -> Rest API -> FREE OFCOURSE WILL DROP HERE 10+ ❤️ reaction required :D
ALL IN ONE AI BUNDLE ✅
ChatGPT ✅
LLAMA ✅
Bard (Under Process...)
Image Generator ✅
There is no usage limit :D
How to use:
https://github.com/TechGPT/HyperGPT/blob/main/hypergpt.py
Coded by @BiswaX
ChatGPT ✅
LLAMA ✅
Bard (Under Process...)
Image Generator ✅
There is no usage limit :D
How to use:
hyper = HyperGPT()
hyper.base_api = "https://api.biswax.dev/{}"
prompt = "what is your name?"
# chatgpt response
print("ChatGPT Response: ")
chatgpt = hyper.chatbot(prompt, model="gpt")
print(chatgpt.response)
# facebook's llama response
print("\nLLAMA Response: ")
llama = hyper.chatbot(prompt, model="llama")
print(llama.response)
# Generate Image
print("\nGenerate Image: ")
imageai = hyper.generate_image("elon musk", model="3d")
print("Image is ready: ", imageai.result)
Source Code:https://github.com/TechGPT/HyperGPT/blob/main/hypergpt.py
Coded by @BiswaX
Please open Telegram to view this post
VIEW IN TELEGRAM
❤13👎4🔥4👍3