This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
static void sumSubArraysFast(int* arr, size_t size){ | |
int i,j,k; | |
int matsize = size * size; | |
int matsizebytes = sizeof(int) * matsize; | |
int* mat = malloc(matsizebytes); | |
memset(mat, 0, matsizebytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
static void printSubArrays(int* arr, size_t size){ | |
int i,j,k; | |
/* subarray sizes */ | |
for(i = 1; i < size; i++){ | |
printf("Subarrays with size %d:\n", i); | |
/* start position of subarray */ | |
for(j = 0; j <= (size - i); j++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log2_integer_recur(x, integer_result, error, multiplier, level): | |
if x > multiplier: | |
x = log2_integer_recur(x, integer_result, error, multiplier*multiplier, level*2) | |
while x > multiplier: | |
x := x / multiplier | |
integer_result := integer_result + level | |
return x | |
else: | |
return x | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Asteroid; | |
class Ship; | |
class Bullet; | |
class GameObject; | |
class CollisionDispatcher { | |
public: | |
virtual bool collidesWith(Asteroid* obj1, GameObject* obj2){ | |
return obj2->collidesWithAsteroid(obj1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), scaling both source and destination with the same factor: | |
Note that: | |
(src*a*k) + (dst*(1-a)*k) = ((src*a) + (dst*(1-a)))*k | |
But since k is a part of a, we have to do some trickery: | |
alpha = (1.0 - (1.0 - alpha)*factor) | |
alpha = 1.0 - (factor - alpha*factor) | |
alpha = 1.0 + (alpha-1)*factor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Can only return Promises | |
function *sync_async_function() { | |
var value1 = yield asyncFunction1(); | |
var value2 = yield asyncFunction2(value1); | |
var value3 = yield asyncFunction3(value2); | |
var value4 = yield asyncFunction4(value3); | |
someSynchronousFunction(value4); | |
}; | |
//Entrypoint for helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
madsy@Singularity:~/arm-devel/lib-src/xmlrpc-c-1.33.18$ arm-linux-gnueabi-cpp -v | |
Using built-in specs. | |
COLLECT_GCC=arm-linux-gnueabi-cpp | |
Target: arm-linux-gnueabi | |
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.7.3 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --disable-libitm --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-checking=release --bu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <climits> | |
#include <cctype> | |
using namespace std; | |
enum AtoiErr { | |
NoError, | |
NotANumber, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECTIONS | |
{ | |
.heap_start : { | |
*(.heap_start); | |
g_heap_start = .; | |
} | |
} | |
INSERT AFTER .bss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#create a null-sink to connect the rtp module to. Use its monitor as a source for the RTP stream | |
pactl load-module module-null-sink sink_name=rtp_sink sink_properties=device.description=rtp_sink | |
#initialize the rtp module and connect it to the rtp null-sink we made | |
pactl load-module module-rtp-recv sink=rtp_sink sap_address=192.168.1.170 latency_msec=1000 | |
#make a loopback route from the null-sink's monitor to the speakers so we can listen to the stream | |
pactl load-module module-loopback source=rtp_sink.monitor sink=identifier_of_your_audio_out | |
#find identifier_of_your_audio_out with "pacmd list-sinks | grep name:" or maybe "pacmd list-sinks | grep name: | grep stereo" |