Skip to content

Instantly share code, notes, and snippets.

View superlucky8848's full-sized avatar

superlucky superlucky8848

  • SuperLucky Works
View GitHub Profile
@superlucky8848
superlucky8848 / MongoConfig.java
Created August 28, 2021 13:04 — forked from miluna/MongoConfig.java
Spring - MongoDB without _class field
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
@superlucky8848
superlucky8848 / DlgWorker.cs
Created December 20, 2018 02:56
Modeled Worker Dialog
namespace soLexiconManager
{
partial class DlgWorker
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
@superlucky8848
superlucky8848 / web.xml
Created July 27, 2018 13:52
Simple XCF non spring restful service config
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<description>Apache CXF REST Endpoint</description>
<display-name>cxfREST</display-name>
<servlet-name>cxfREST</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
<init-param>
<param-name>jaxrs.serviceClasses</param-name>
<param-value>com.speechocean.soLexiconWeb.test.RESTWebServiceTest</param-value>
@superlucky8848
superlucky8848 / SHBrosweForFolder.cpp
Created April 5, 2016 02:53
Sample for using folder browser in Windows C++ desktop app.
int CALLBACK BrowserCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
switch (uMsg)
{
case BFFM_INITIALIZED:
::SendMessage(hWnd, BFFM_SETSELECTION, 1, lpData);
break;
default:
break;
}
@superlucky8848
superlucky8848 / CStringCodeConverter.cpp
Last active January 3, 2023 09:54
MFC Convert CString encoding between UTF-8 and UTF-16
static CStringA UTF16_UTF8(const CStringW& utf16)
{
if (utf16.IsEmpty()) return "";
CStringA utf8;
int cc = 0;
if ((cc = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, 0, 0) - 1) > 0)
{
char * buf = utf8.GetBuffer(cc);
if (buf) WideCharToMultiByte(CP_UTF8, 0, utf16, -1, buf, cc, 0, 0);
@superlucky8848
superlucky8848 / GetFileVersion.cpp
Created April 4, 2016 02:25
C++ Get file version and return formatted string(Windows)
#pragma comment(lib,"Version.lib")
#define MAX_LINE_LENGTH 4096
CString GetFileVersion(LPCTSTR filePath)
{
CString ret(_T(""));
DWORD dummy;
DWORD dwSize = GetFileVersionInfoSize(filePath, &dummy);
if (dwSize == 0) ret = _T("Error retriving version(Module Not Found)");
@superlucky8848
superlucky8848 / GetFileWriteAccess.cs
Last active January 12, 2016 11:30
(C# Windows) Check if a file path (relative or absolute) can be written by current user without attempting to create open or actually write anything to it. Inspired by http://stackoverflow.com/questions/1281620/checking-for-directory-and-file-write-permissions-in-net
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
private bool FileCanWrite(string path)
{
bool writeAllow = false;
bool writeDeny = false;
try
@superlucky8848
superlucky8848 / VBARecipies
Last active August 29, 2015 14:05
Easy to use VBA Recipies for MS Office
'[Word] Convert auto generated number to plain text.
ActiveDocument.Content.ListFormat.ConvertNumbersToText
'[Excel] Clear all hyperlinks in current sheet (Useful when copy some linked sheet from web)
ActiveWorkbook.ActiveSheet.HyperLinks.Delete
'[Excel] Safest way get totol rows or cols count for specific table (http://stackoverflow.com/questions/6301665/how-to-count-the-number-of-rows-in-excel-with-data)
rowCnt = targetSheet.Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
colCnt = targetSheet.Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
@superlucky8848
superlucky8848 / splitContainer_Paint
Last active August 29, 2015 14:04
Give .NET Winform splitContainer Control a visible paddle for movable splitter
private void splitContainer_Splitter_Paint(object sender, PaintEventArgs e)
{
SplitContainer control = sender as SplitContainer;
if(control == null) return;
//paint the three dots'
Point[] points = new Point[3];
int w = control.Width;
int h = control.Height;
int d = control.SplitterDistance;
int sW = control.SplitterWidth;
@superlucky8848
superlucky8848 / StringDistance.cs
Last active November 2, 2015 12:55
Compair two List<string> find minium changes from source to target. (Add, remove and modify count as a change), return one of the optimal change steps.
using System;
using System.Collections.Generic;
using System.Text;
namespace ProofReadingCorrect
{
enum EditType
{
NONE = 0,
CHANGE = 1,