我在我的linux计算机上正确设置了MySQL,但是我想要一种更好的方法将数据输入到终端之外的数据库中.出于这个原因,我下载了phpMyAdmin.但是,当我尝试从index.php登录phpMyAdmin时,它什么也没做.它似乎只是刷新页面而不做任何事情.我正在输入正确的MySQL用户名和密码.有什么问题?
这是我点击"go"后显示的屏幕截图.

考虑以下同构结构:
struct myStruct {
void* a;
char* b;
int* c;
};
Run Code Online (Sandbox Code Playgroud)
我相信它是同类的,因为所有的数据类型都是指针.
鉴于此结构,以下代码在C99中是否有效且可移植?
int main()
{
void* x = NULL;
char* y = "hello";
int* z = malloc(sizeof(int) * 10);
z[2] = 10;
void** myArray = malloc(sizeof(void*) * 3);
myArray[0] = x;
myArray[1] = y;
myArray[2] = z;
struct myStruct* s = (struct myStruct*)myArray;
printf("%p %s %d\n", s->a, s->b, s->c[2]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我知道结构通常会在组件之间添加填充以保持结构的大小一致,但是,因为指针的类型都是相同的,是否可以安全地假设不添加填充?我不一定要问是否有100%的保证(我明白这完全是特定于实现的,并且编译器可能因为不明原因而添加填充),更多我要求填充可能添加到同构结构的原因,如有任何理由的话.
此代码使用用于从伴随对象访问常量的限定名称成功编译:
enum class CampsiteCategoryCode(val code: String) {
TENT(CampsiteCategoryCode.TENT_CODE), // intellij says 'Redundant qualifier name'
OTHER(CampsiteCategoryCode.OTHER_CODE), // intellij says 'Redundant qualifier name'
LODGING(CampsiteCategoryCode.LODGING_CODE), // intellij says 'Redundant qualifier name'
RV(CampsiteCategoryCode.RV_CODE); // intellij says 'Redundant qualifier name'
override fun toString() = code
companion object {
const val TENT_CODE = "tent"
const val OTHER_CODE = "other"
const val LODGING_CODE = "lodging"
const val RV_CODE = "rv"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,没有限定符名称的相同代码将使编译失败:
enum class CampsiteCategoryCode(val code: String) {
TENT(TENT_CODE), // Variable 'TENT_CODE' must be initialized
OTHER(OTHER_CODE), …Run Code Online (Sandbox Code Playgroud) 在测试小字符串(例如isPhoneNumber或isHexadecimal)时,使用正则表达式会带来性能上的好处,还是会强制它们更快?不会通过检查给定字符串的字符是否在指定范围内比使用正则表达式更快来强制它们吗?
例如:
public static boolean isHexadecimal(String value)
{
if (value.startsWith("-"))
{
value = value.substring(1);
}
value = value.toLowerCase();
if (value.length() <= 2 || !value.startsWith("0x"))
{
return false;
}
for (int i = 2; i < value.length(); i++)
{
char c = value.charAt(i);
if (!(c >= '0' && c <= '9' || c >= 'a' && c <= 'f'))
{
return false;
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
与
Regex.match(/0x[0-9a-f]+/, "0x123fa") // returns true if regex matches whole given expression
Run Code Online (Sandbox Code Playgroud)
似乎有一些与正则表达式相关的开销,即使模式是预编译的,只是因为正则表达式必须在许多一般情况下工作.相比之下,蛮力方法完全符合要求而不再需要.我错过了正则表达式的一些优化吗?
我正试图通过javascript API从我的LinkedIn个人资料中获取只读公开信息.我目前有这个代码,我知道这个代码是不完整的:
<script>
function linkedinAuthorized() {
console.log("Linked in authorized");
}
function linkedinLoaded() {
console.log("Linked in loaded");
IN.Event.on(IN, "auth", linkedinAuthorized);
var url = "/people/~?format=json";
IN.API.Raw()
.url(url)
.method("GET")
.result(function (result) {
console.log(result);
})
.error(function (error) {
console.log(error);
});
}
</script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [my key]
onLoad: linkedinLoaded
</script>
Run Code Online (Sandbox Code Playgroud)
我能够成功加载链接,但是当执行IN.API.Raw调用时,我得到:
我怀疑是因为我没有使用其中一个LinkedIn登录按钮登录帐户.
我的问题是,如果不通过其中一个手动授权流程,我是否可以从特定用户获取只读配置文件信息?
我创建了一个带有JDBC的java程序,它成功连接到我的计算机服务器的MySQL数据库,如下所示:
try
{
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception ex)
{
// handle the error
}
try
{
conn = DriverManager.getConnection(("jdbc:mysql://191.168.1.15:3306/databasename"), "username", "password");
// Do something with the Connection
}
catch (SQLException ex)
{
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
Run Code Online (Sandbox Code Playgroud)
但是,如果有人想要找出密码,那么使用任何java反编译器都会非常简单.我怎么能阻止他们找到密码或用户名呢?
我试过了
ClassWriter t = new ClassWriter(0);
t.visitSource("testing.java", null);
t.visitEnd();
byte d[] = t.toByteArray();
FileOutputStream p = null;
try
{
p = new FileOutputStream("testing.class");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
try
{
p.write(d);
}
catch (IOException e)
{
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
testing.java 中的文本是:
public class testing
{
public static void main(String args[])
{
System.out.println("Works!");
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行类文件时,它给了我这个错误:
Exception in thread "main" java.lang.UnsupportedClassVersionError: testing : Unsupported major.minor version 0.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58) …Run Code Online (Sandbox Code Playgroud) 如果您需要编译的唯一语言是C,是否有较小的GCC下载?TCC是Windows的绝佳选择,但我需要它在几个平台上编译.我也喜欢GCC非常常用的事实.
如果没有更小的特定下载,我是否可以清除下载包中不需要编译C的数据?这种方法会有问题吗?
c ×2
java ×2
mysql ×2
assembly ×1
brute-force ×1
c++ ×1
enums ×1
gcc ×1
javascript ×1
jdbc ×1
kotlin ×1
linkedin ×1
linux ×1
performance ×1
phpmyadmin ×1
regex ×1
sql ×1
sql-server ×1
string ×1
struct ×1
tcc ×1