Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
// Paths to files
const versionTagPath = path.join(__dirname, 'version-tag');
const packageJsonPath = path.join(__dirname, 'package.json');
const devYamlPath = path.join(__dirname, 'html/environments/dev.yaml');
// Read version from version-tag file
const fs = require('fs');
const path = require('path');
// Read version from version-tag file
const versionTagPath = path.join(__dirname, 'version-tag');
const packageJsonPath = path.join(__dirname, 'package.json');
const version = fs.readFileSync(versionTagPath, 'utf-8').trim();
if (!version) {
import os
import psycopg2
import requests
from exchangelib import Credentials, Account, Message, DELEGATE, HTMLBody
from email.mime.application import MIMEApplication
# PostgreSQL Database Configuration
DB_CONFIG = {
"dbname": "your_database",
"user": "your_db_user",
import os
import psycopg2
from datetime import datetime
from exchangelib import Credentials, Account, DELEGATE
# Outlook Configuration
OUTLOOK_EMAIL = "[email protected]" # Your technical user email
OUTLOOK_PASSWORD = "your_password" # Your password
SHARED_MAILBOX = "[email protected]" # The shared mailbox
FOLDER_NAME = "Inbox" # Folder to check emails from
@levancho
levancho / contracts...LuckyChainSimple.sol
Created July 29, 2024 07:50
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
import "hardhat/console.sol";
contract LuckyChainSimple {
address public manager;
uint public level = 1;
uint public totalSeats = 0;
@levancho
levancho / gist:25e1f63a957cd44e1a88dc0ffd4d41df
Created July 16, 2024 17:27
how to write in select in mybatis
@Select({"<script>",
SELECT_PRODUCTS,
"WHERE desp_product.oid IN",
"<foreach item='oidItem' index='index' collection='oids'",
"open='(' separator=',' close=')'>",
"#{oidItem}",
"</foreach>",
"</script>"})
@ResultMap("noParrent")
public List<DespProduct> getAllProductsIn(@Param("oids") List<Integer> oids) ;
PublicClientApplication app = PublicClientApplication.builder("YOUR_CLIENT_ID")
.authority("https://login.microsoftonline.com/YOUR_TENANT_ID")
.build();
RefreshTokenParameters parameters = RefreshTokenParameters.builder(
Collections.singleton("YOUR_SCOPE"),
"YOUR_REFRESH_TOKEN")
.build();
Future<IAuthenticationResult> future = app.acquireToken(parameters);
POST http://yourserver.com/your-endpoint
Content-Type: multipart/form-data; boundary=boundarystring
--boundarystring
Content-Disposition: form-data; name="file"; filename="sample.txt"
Content-Type: text/plain
< ./path-to-your-file/sample.txt
--boundarystring--
try (OutputStream os = enc.getDataStream(fs)) {
os.write(inputExcel);
}
// Convert the POIFSFileSystem to a byte array
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
fs.writeFilesystem(baos);
return baos.toByteArray();
}
public static byte[] passwordProtectExcel(byte[] inputExcel) throws IOException, GeneralSecurityException {
// Convert the input byte array to a Workbook
XSSFWorkbook workbook = new XSSFWorkbook(new ByteArrayInputStream(inputExcel));
// Prepare to encrypt the workbook
POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
Encryptor enc = info.getEncryptor();
enc.confirmPassword("password"); // Set the password here