Tag Archives: English

A simple EventEmitter in C++

EventEmitter coming with node.js is handy most of the time, and I implement this useful utility in C++ after finishing writing Functor. Yes, we need Functor to make it much more easier to write this fabulous utility. (Why don't you use lamdba? I'll talk about that later in this post)

It's extremely simple to use EventEmitter in node.js

const EventEmitter = require('events');

class MyEmitter extends EventEmitter {}

const myEmitter = new MyEmitter();
myEmitter.on('event', () => {
    console.log('an event occurred!');
});
myEmitter.emit('event');

——https://nodejs.org/api/events.html

And the C++ version of EventEmitter need to be as easy as it is in node.js. As a matter of fact, this class made it.

#include <iostream>
#include <sstream>
#include <thread>
#include <vector>
#include "EventEmitter.hpp"

using namespace std;

class emitter : public EventEmitter {
};

int main(int argc, const char * argv[]) {
    emitter emitter;
    emitter.on("event", [&emitter](int data) {
        ostringstream osstream;
        osstream << "data: " << data << '\n';
        std::cout << osstream.str();
    });

    vector<thread> threads;
    for (int i = 0; i < 10; i++) {
        threads.emplace_back([&emitter, i]() {
            emitter.emit("event", i);
        });
    }

    for (auto &t : threads) t.join();
}

Continue reading A simple EventEmitter in C++

"Swift support" for class-dump

I added "Swift support" for class-dump.

Now, this tool can dump Objective-C headers even the MachO file uses Swift and ObjC at the same time. Notice, only ObjC headers can be dumped!

LAST, THIS IS AN EXPERIMENTAL VERSION.

我为class-dump添加了"Swift支持"。

现在,这个工具可以dump出可执行文件的Objective-C头文件,即使那个MachO文件同时使用了Swift和ObjC。请注意只有ObjC类的头文件可以被dump出来!

最后,这只是一个试验版本。

Git:
class-dump with "Swift support"

"Swift support" for class-dump

I added "Swift support" for class-dump.

Now, this tool can dump Objective-C headers even the MachO file uses Swift and ObjC at the same time. Notice, only ObjC headers can be dumped!

LAST, THIS IS AN EXPERIMENTAL VERSION.

我为class-dump添加了"Swift支持"。

现在,这个工具可以dump出可执行文件的Objective-C头文件,即使那个MachO文件同时使用了Swift和ObjC。请注意只有ObjC类的头文件可以被dump出来!

最后,这只是一个试验版本。

Git:
class-dump with "Swift support"

Bypass sandbox and present an alert in other apps

There is a historic way to present your alert in other apps, which can date back to iOS 5 or even easier.

You can refer to those links.
Can you use CFUserNotification with IOS 5.1
Display CFUserNotificationDisplayAlert on iPhone Lock Screen
There is even a wiki page on iPhoneDevWiki, CFUserNotification.
(Update 1) Here is the official source code from Apple.

Recently, this guy who comes up with a possible way of using this old method to steal Apple ID.

Continue reading Bypass sandbox and present an alert in other apps

The analysis of how to specific a port to device with iOSOpenDev

Yesterday I wrote a post about How to specific a port to device with iOSOpenDev. It's more like a tutor due to lacking of the process of analysis. So I decide to write about the process how did I analyze it so you can add this feature on yourselves when iOSOpenDev updates someday.

I'll keep this post as simple as I can, but I'll assume you've already had some basic knowledge.

Continue reading The analysis of how to specific a port to device with iOSOpenDev

MIT Algorithms (3)


Sorting
    -How fast can we sort
    -It depends on model:)
    
    the model is of what you can do with the elements
    
    e.g
        Quicksort       θ(nlgn)  
        Heapsort        θ(nlgn)
        merge sort      θ(nlgn)
        insertion sort  θ(n2)
        
    so, can we do better than θ(nlgn)?
Continue reading MIT Algorithms (3)

Swift and Objective-C tweak supporting

With increment of swift, it's not ridiculous that using swift when you do some jailbreak development. If the tweak can get a better UI and I can code easier, there is no reason to refuse swift.

But one thing we should care about is that, Xcode 6 (and later) will link swift's dylib something like @rpath/libswiftDarwin.dylib.

That means if you didn't put those dylib files into a directory named `Frameworks` which right under your executable file's directory, it will just crash when you try to launch them.

Continue reading Swift and Objective-C tweak supporting

Here's to the crazy ones

Here's to the crazy ones: the misfits, the rebels, the troublemakers, the round pegs in the square holes, the ones who see things differently. 

They are not fond of rules. They have no respect of status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can't do, is ignore them, because they change things. They push human race forward.

Some may see them as the crazy ones. We see genius,because the people who are crazy enough to think they can change the world ... are the ones who do.