Skip to content

Instantly share code, notes, and snippets.

View preslavrachev's full-sized avatar

Preslav Rachev preslavrachev

View GitHub Profile
/* we are using the assumption that every entity is constructed recursively as every child component is given an id of +1
so it could be that my id is #5, but if I have 7 child components, the ID of my next neighbor (the next entity constructed by my parent, which is on the same tree level ) will be #13, because I will be constructed recursively to the lowest level first */
public static void sendMessage(String methodName, Object args)
{
int id = 5;
int parentId = 0;
@preslavrachev
preslavrachev / test.js
Created July 19, 2012 10:01
Matching multiple hashtags in javascript
var c = "it ws a #nice and #sunny day in Berlin";
c.match(/\B#\w*[a-zA-Z]\w*/g); //should return #nice and #sunny
var p = function() {
console.log("Executing the callback function");
}
var c = function(callBack) {
console.log("Executing the wrapper function");
}
c(p);
#include <iostream>
using namespace std;
void theWrapperFunction(int (*fnc) ()) {
cout << fnc();
}
int theCallBackFunction() {
return 12345;
}
#include <iostream>
#include "pixel.h"
using namespace std;
typedef int (*FunctionFunc)(); // check that out!!!
void theWrapperFunction(FunctionFunc fnc) {
cout << fnc();
}
class TestClass {
var a:String;
public function new() {
this.p = "test1";
}
}
....
class TestClass implements Dynamic { // this is the crucial part
var a:String;
public function new() {
this.p = "test1";
}
}
....
@preslavrachev
preslavrachev / .building.txt
Created September 8, 2012 11:18
Executing Objective-C code from Haxe (Using NME's native extensions)
#in the Extension folder:
haxelib run hxcpp Build.xml -Diphoneos #device
#or
haxelib run hxcpp Build.xml -Diphonesim #simulator
#or
@preslavrachev
preslavrachev / test1.js
Last active October 10, 2015 15:38
JavaScript's assignment operation in more detail
var x = 2 // x gets a reference to the value of the scalar 2;
var y = x // also gets a reference to the value of the scalar 2; Please, note that y does not refer to x, but //to the value to which x refers. That will make more sense in the later examples.
x++;
y = ??? x = ??? // x == 3, while y==2, because x was given a new reference to the value of the scalar 3. Since //y points a reference to the value of the scalar 2, and not to x, it keeps the value
@preslavrachev
preslavrachev / find_friend_app_users.sql
Created May 2, 2013 08:05
Find which friends of yours are using a particular Facebook-connected application. Unlike other approaches, using this FQL query, one will fetch only those among one's friends, who are actually using the application. The application in question depends on the access token being passed in the request
SELECT uid,name,is_app_user FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())