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
#include <string> | |
#include <functional> | |
using namespace std; | |
template <typename T> | |
struct Maybe{ | |
T just; | |
bool isNothing; | |
}; |
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
import psycopg2 | |
from datetime import datetime | |
def printline(r): | |
correspondence_id, account_id, case_id, created_date, internal_external_flag, to_line, from_line, cc_line = r | |
print(f"{correspondence_id},{account_id},{case_id or ''},{created_date.isoformat()},{internal_external_flag},{to_line},{from_line},{cc_line or ''}") | |
###### | |
user = 'username' |
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
static void clear(String source) { | |
try { | |
Field charField = String.class.getDeclaredField("value"); | |
charField.setAccessible(true); | |
SecureRandom random = SecureRandom.getInstanceStrong(); | |
char[] noise = new char[source.length()]; | |
for (int i = 0; i < source.length(); i++) { | |
noise[i] = (char) random.nextInt(Character.MAX_VALUE + 1); | |
} |
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
////// | |
// https://www.postgresqltutorial.com/postgresql-jdbc/transaction/ | |
///// | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
import java.sql.DriverManager; | |
import java.sql.ResultSet; | |
import java.sql.Statement; |
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
package com.labex; | |
import java.sql.*; | |
public class JDBCTest { | |
// JDBC driver name | |
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; | |
//database url | |
static final String DB_URL = "jdbc:mysql://localhost/example"; |
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
Statement stmt = conn.createStatement( | |
ResultSet.TYPE_SCROLL_INSENSITIVE, | |
ResultSet.CONCUR_UPDATABLE); | |
String sql = "SELECT id, name, age FROM students"; | |
ResultSet rs = stmt.executeQuery(sql); | |
// update data in Result Set | |
rs.moveToInsertRow(); | |
rs.updateInt("id",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
public class test { | |
public static void main(String[] args) { | |
// get date and time | |
// here we use java.util.Date class for comparison with java.sql.Date | |
java.util.Date javaDate = new java.util.Date(); | |
long javaTime = javaDate.getTime(); | |
System.out.println("The Java Date is:" + | |
javaDate.toString()); | |
// get SQL date in java.sql.Date format |
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 loadJquery() { | |
var jq = document.createElement('script'); | |
jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
jQuery.noConflict(); | |
}; | |
function moveSim(id) { | |
payload = { | |
??? |
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
///////////// | |
// use transactions | |
try | |
{ | |
// close auto commit | |
conn.setAutoCommit(false); | |
//1 or more queries or updates |
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
public List<User> getUser(int userId) { | |
try (Connection con = DriverManager.getConnection(myConnectionURL); | |
PreparedStatement ps = createPreparedStatement(con, userId); | |
ResultSet rs = ps.executeQuery()) { | |
// process the resultset here, all resources will be cleaned up | |
} catch (SQLException e) { | |
e.printStackTrace(); | |
} |