Skip to content

Instantly share code, notes, and snippets.

View j2doll's full-sized avatar
πŸ’­
1️⃣ πŸ˜„ 2️⃣ 😭

Jay Two j2doll

πŸ’­
1️⃣ πŸ˜„ 2️⃣ 😭
View GitHub Profile
@j2doll
j2doll / xlnt-write-xlsx.cpp
Created October 18, 2017 06:20
write a xlsx file
#include <iostream>
#include <xlnt/xlnt.hpp>
#include <vector>
#include <string>
int main()
{
//Creating a 2 dimensional vector which we will write values to
std::vector< std::vector<std::string> > wholeWorksheet;
@j2doll
j2doll / QtMOC.cpp
Created January 16, 2018 07:50
Qt MOC sample #1
// class MyWidget : public QWidget
QObject *obj = new MyWidget;
QWidget *widget = qobject_cast<QWidget *>(obj);
Q_ASSERT( widget != NULL );
MyWidget *myWidget = qobject_cast<MyWidget *>(obj);
Q_ASSERT( myWidget != NULL );
@j2doll
j2doll / to_file.rb
Created January 18, 2018 08:15
Sample of Ruby mixin
=begin
to_file.rb
sample of 'mixin'
=end
module ToFile
def filename
"object_#{self.object_id}.txt"
end
def to_f
@j2doll
j2doll / timeConsumingFunction.cpp
Created January 19, 2018 06:45
QtConcurrent : MapReduce
#include <climits>
#include <QtGlobal>
#include <QString>
#include <QDebug>
#include <QtCore>
#include <QtCore/QCoreApplication>
#include <QThread>
#include <QtConcurrentRun>
#include <QTime>
@j2doll
j2doll / cpp.lambda.ko.md
Last active November 15, 2024 06:01
C++ λžŒλ‹€(lambda) ν‘œν˜„μ‹ 이해와 ν™œμš© 예제

C++ λžŒλ‹€(lambda) ν‘œν˜„μ‹ 이해와 ν™œμš© 예제

C++11λΆ€ν„° λ„μž…λœ λžŒλ‹€ ν‘œν˜„μ‹μ€ 읡λͺ… ν•¨μˆ˜(anonymous function)λ₯Ό μ •μ˜ν•˜λŠ” 데 μ‚¬μš©λ˜λ©°, μ½”λ“œμ˜ κ°„κ²°μ„±κ³Ό 가독성을 λ†’μ—¬μ€λ‹ˆλ‹€. 특히, ν•¨μˆ˜ κ°μ²΄λ‚˜ ν•¨μˆ˜ 포인터λ₯Ό λŒ€μ²΄ν•˜μ—¬ 콜백 ν•¨μˆ˜λ‚˜ μΌνšŒμ„± ν•¨μˆ˜ μ •μ˜μ— μœ μš©ν•˜κ²Œ ν™œμš©λ©λ‹ˆλ‹€.

λžŒλ‹€ ν‘œν˜„μ‹μ˜ κΈ°λ³Έ 문법은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€:

cpp

[capture](parameters) -> return_type {
 // ν•¨μˆ˜ λ³Έλ¬Έ
@j2doll
j2doll / Using-Spritesheets-with-Cocos2d-X.cpp
Created February 21, 2018 07:50
Using Spritesheets with Cocos2d-X
// Using Spritesheets with Cocos2d-X
// http://paralaxer.com/animation-spritesheets/
//------------------------------------------------------------------
// So how does one use a spritesheet with Cocos2d-X?
// The first thing you've got to do is load the texture file
// and cache the sprite frames:
// set the appropriate resource directory for this device. HD/HDR/SD, etc...
CCFileUtils::sharedFileUtils()->setResourceDirectory( "HD" );
@j2doll
j2doll / StreamingException.h
Created March 19, 2018 10:10
StreamingException
// code from Dr.Dobbs (http://www.drdobbs.com/)
// StreamingException.h
//
#ifndef STREAMING_EXCEPTION
#define STREAMING_EXCEPTION
#include <iostream>
#include <sstream>
#include <memory>
@j2doll
j2doll / testException.cpp
Created March 19, 2018 10:11
TestException
// testException.cpp
#include "StreamingException.h"
int main (int argc, char * const argv[])
{
try
{
if (5 != 3)
throw StreamingException() << 5 << " is not equal to " << 3;
@j2doll
j2doll / HelloPyQt5.py
Created March 23, 2018 06:45
Hello, PyQt5
# HelloPyQt5.py
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle('Hello World')
w.show()
@j2doll
j2doll / TestCArchiveCString.cpp
Created March 30, 2018 03:09
Tes tCArchive CString
TCHAR pFileName[] = _T("test123.test");
CFile f;
if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite ) ) {
#ifdef _DEBUG
afxDump << _T("Unable to open file\n");
exit( 1 );
#endif
}
CArchive ar( &f, CArchive::store );