Skip to content

Instantly share code, notes, and snippets.

@DerexScript
DerexScript / fetchPostForm.html
Created September 16, 2022 22:49
post using Content-Type application/x-www-form-urlencoded with fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
</head>
@DerexScript
DerexScript / kpmToKeePassXC.js
Created September 11, 2022 17:21
kpmToKeePassXC
const readLine = require('readline');
const fs = require('fs');
const regexWN = new RegExp('Website name:\\s([^\n]+)', '');
const regexWU = /Website URL: ([^\n]+)/;
const regexLN = /Login name: ([^\n]+)/;
const regexL = /Login: ([^\n]+)/;
const regexPW = /^Password: ([^\n]+)/;
const regexC = /Comment:/;
@DerexScript
DerexScript / login.php
Created May 20, 2022 05:38
login.php
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
header('Content-type: application/json');
if (isset($_POST['user']) && isset($_POST['password'])) {
$jsonArr = ["status" => "true", "POST" => $_POST];
echo json_encode($_POST);
} else {
@DerexScript
DerexScript / sendFormDataToServerWithFetch.html
Last active May 20, 2022 05:49
sendFormDataToServerWithFetch.html
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test Front and Back</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
@DerexScript
DerexScript / mic-loopback.sh
Created November 29, 2021 06:09 — forked from iamc/mic-loopback.sh
script to enable/disable pulseaudio loopback module in order to get eg. mic feedback
#!/bin/bash
#
# Loads / unloads pulseaudio loopback module in order to eg. be redirect
# mic input to headphones.
#
# Usage: mic-loopback [on|off]
#
if [ $# -ne 1 ]; then
echo "Usage: $0 [on|off]"
@DerexScript
DerexScript / xhr.js
Created October 12, 2021 16:31
xhr.js
var form = new FormData;
var xhr = new XmlHttpRequest;
xhr.open('path/to/api', 'POST', true);
xhr.onreadystatechange = function(e) {
console.log(e); // Check success/fail
}
var toSendData = {
proName: [
'Product 1',
void function() {//closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@DerexScript
DerexScript / Laravel_Global_Installer.sh
Created July 21, 2021 00:11 — forked from arvinesmaeily/Laravel_Global_Installer.sh
Laravel Global Installer (Including PHP, Composer and PHP extensions)
#!/bin/sh
sudo apt-get update && apt-get upgrade
sudo apt-get install php
sudo apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
function str_replace_last(search, replace, str){
let pos = str.lastIndexOf('webp');
let search_length;
if(pos != -1){
search_length = search.length;
str = str.substring(0, pos)+replace+str.substring(pos+search_length);
}
return str;
}