Skip to content

Instantly share code, notes, and snippets.

View icecoobe's full-sized avatar
🎯
Focusing

Luke icecoobe

🎯
Focusing
View GitHub Profile
#!/usr/bin/python
# Desc: Demostrate the usage of __str__ and __repr__ magic methods
""" Demostrate the usage of __str__ and __repr__ magic methods
"""
# class TestClass(object):
class TestClass():
# 定义对象的初始化行为
def __init__(self):
#include <iostream>
#include <mutex>
#include <thread>
namespace
{
std::once_flag init_once_flag;
}
class singleton
@icecoobe
icecoobe / hex_item_delegate.hpp
Last active September 21, 2023 11:23
Make some row/col can only accept hex-style input for QTableWidget ;
#include <QLineEdit>
#include <QStyledItemDelegate>
/*
// Sample
auto delegate = new HexItemDelegate;
ui->tableInfo->setItemDelegateForColumn(1, delegate);
ui->tableInfo->setItemDelegateForRow(1, delegate);
ui->tableInfo->setItemDelegate(delegate);
*/
@icecoobe
icecoobe / sentence_similarity.cpp
Created July 26, 2023 09:24
calculate similarity of 2 sentences
#include <iostream>
#include <iterator>
#include <algorithm>
#include <sstream>
#include <unordered_set>
namespace
{
void to_lower(std::string& str)
@icecoobe
icecoobe / info.sh
Created May 6, 2023 01:53
output information to console under shell
#!/bin/bash
##############################################################################
# Print information to stdout in bold green style
# Globals:
# None
# Arguments:
# None
# Outputs:
# Writes information to stdout
@icecoobe
icecoobe / win_shared_mem-2.cpp
Created January 13, 2023 05:59
windows shared memory sample - 2
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string strMapName("ShareMemory");
@icecoobe
icecoobe / win_shared_mem.cpp
Created January 13, 2023 03:49
Windows shared memory sample
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string strMapName("ShareMemory");
@icecoobe
icecoobe / linked_list.hpp
Created January 4, 2023 11:26
linked list
#pragma once
#include <iostream>
template <typename T>
class linked_list
{
public:
static const size_t k_invalid_pos = 0xFFFF;
@icecoobe
icecoobe / two_sum.cpp
Last active January 4, 2023 11:24
two sums, leetcode-1
#include <iostream>
#include <vector>
#include <map>
using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
@icecoobe
icecoobe / count_one_bit.cpp
Last active January 4, 2023 11:21
count 1 bits
#include <iostream>
size_t count_one_bit(uint64_t num)
{
size_t count = 0x0;
while (num > 0x0)
{
if ((num & 0x01) != 0)