Skip to content

Instantly share code, notes, and snippets.

View hlgsdx's full-sized avatar

hlgsdx

View GitHub Profile
@hlgsdx
hlgsdx / main.cpp
Created June 26, 2017 04:56
wait() & waitpid() & kill() in Linux
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
pid_t childpid,childpid2;
int status;
import threading
import random
import time
total_tickets = 5
lock = threading.Lock()
def sellOut(sellerId, paymentWait):
global total_tickets
@hlgsdx
hlgsdx / StuSqlite.py
Last active December 12, 2017 12:04
实现基于数据库的学生信息录入系统——综合应用GUI的多种控件及数据库连接和访问技术实现学生信息录入系统
# -*- coding: utf-8 -*-
import wx
import sqlite3
class LoginFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition,
size=wx.Size(350, 200), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
@hlgsdx
hlgsdx / Test.py
Created December 12, 2017 14:19
SQLite3 Basic Operations in Python3
import sqlite3
'''
student(sno,sname,sage)
course(cno,cname)
sc(sno,cno,grade)
1.创建三个表
2.分别向三个表插入数据:
(1,mike,19),(2,john,18),(3,mary,18)
@hlgsdx
hlgsdx / permission.CALL_PHONE.java
Created February 17, 2018 14:59
Android运行时权限申请
//参考资料 https://www.cnblogs.com/wwjldm/p/6932083.html
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == 1) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
Toast.makeText(this, "已授权", Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, "未授权", Toast.LENGTH_SHORT).show();
return;
@hlgsdx
hlgsdx / Main.java
Created February 19, 2018 14:09
遇到的一个坑
package com.github;
import java.util.Random;
class Students {
private final int sid;
Students(int sid) {
this.sid = sid;
}
@hlgsdx
hlgsdx / Main.java
Created February 20, 2018 12:07
Lambda表达式实现接口有关的匿名类
interface hello {
void say();
}
class sayHallo {
sayHallo(hello hallo) {
hallo.say();
}
}
@hlgsdx
hlgsdx / exe2fbr.sh
Created May 19, 2018 13:30
Convert the exe export of BBFlashBackPro5 to the original fbr format
#!/bin/bash
Tmp_file=${1}".tmp"
Output=${1}".fbr"
dd ibs=1122304 skip=1 if="$1" of="$Tmp_file"
head -c -161 "$Tmp_file" > "$Output"
rm "$Tmp_file"
@hlgsdx
hlgsdx / main.cpp
Created May 27, 2018 11:48
SDL2:Getting an Image on the Screen
#include <SDL.h>
#include <cstdio>
using namespace std;
//窗口宽
const int SCREEN_WIDTH = 1024;
//窗口高
const int SCREEN_HEIGHT = 768;
@hlgsdx
hlgsdx / main.cpp
Created May 27, 2018 13:44
SDL2:事件驱动
#include <SDL.h>
#include <cstdio>
#include <iostream>
using namespace std;
//窗口宽
const int SCREEN_WIDTH = 1024;
//窗口高
const int SCREEN_HEIGHT = 768;