Skip to content

Instantly share code, notes, and snippets.

@arielm
arielm / GenomicRangeQuery.java
Last active September 11, 2016 14:59
Solution (100%) to GenomicRangeQuery problem on Codility (https://codility.com/programmers/task/genomic_range_query/)
/*
* I WAS ONLY CAPABLE OF FINDING AN O(N*M) SOLUTION
*
* THE O(N+M) SOLUTION PRESENTED HERE IS BASED ON:
* http://csharplabtests.blogspot.co.il/2015/06/codility-lesson-3-genomicrangequery.html
*/
class Solution
{
public int[] solution(String S, int[] P, int[] Q)
@arielm
arielm / MinAvgTwoSlice.java
Last active April 29, 2020 13:39
Solution (100%) to MinAvgTwoSlice problem on Codility (https://codility.com/programmers/task/min_avg_two_slice)
/*
* ABSOLUTELY NON-TRIVIAL (AND CERTAINLY NOT DOABLE WITHIN A SHORT TIME FRAME):
* IT'S NECESSARY TO FIND OUT FIRST THAT ONLY SLICES OF LENGTH 2 OR 3 MATTER
*
* PROOF:
* https://codesays.com/2014/solution-to-min-avg-two-slice-by-codility
*
* NOTE: THE USAGE OF "PREFIX-SUMS" IS NOT PURELY NECESSARY
* (BUT IT WAS IN PLACE AT THE TIME I STILL BELIEVED THAT SLICES
* OF ARBITRARY LENGTHS COULD BE INVOLVED...)
@arielm
arielm / anisotropy.cpp
Created September 29, 2015 20:19
Emscripten minimal test-case for showcasing issue with anisotropic filtering
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdio.h>
#include <emscripten.h>
#include <emscripten/html5.h>
int main()
{
emscripten_set_canvas_size(256, 256);
/*
* REFERENCE: https://github.com/arielm/chronotext-boost/wiki/Basic-code-sample
*/
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
@arielm
arielm / build.sh
Last active February 18, 2019 05:36
TESTING EMSCRIPTEN WITH C++11 AND BOOST
# BUILDING BOOST FOR EMSCRIPTEN...
# REFERENCE: http://www.boost.org/doc/libs/1_58_0/more/getting_started/unix-variants.html
# TESTED WITH: BOOST 1.53 ON OSX 10.10
# DEPENDS ON: MODIFIED user-config.jam
# REQUIRED FOR iostreams
# REFERENCE: http://www.boost.org/doc/libs/1_58_0/libs/iostreams/doc/installation.html#bjam
cd $EMSCRIPTEN_PATH; ./embuilder.py build zlib
export NO_BZIP2=1
@arielm
arielm / build_debug.sh
Created January 29, 2015 22:08
The path for this file should be: mozjs-31.2.0/js/src/build-osx
#!/bin/sh
cpus=$(sysctl hw.ncpu | awk '{print $2}')
../configure --disable-tests --disable-shared-js --enable-llvm-hacks \
--without-intl-api \
--disable-threadsafe \
--enable-exact-rooting --enable-gcgenerational \
--enable-gczeal --enable-root-analysis \
--enable-debug --enable-debug-symbols \
@arielm
arielm / build.sh
Created January 29, 2015 22:03
The path for this file should be: mozjs-31.2.0/js/src/build-android
#!/bin/sh
if [ -z $NDK_ROOT ]; then
echo "NDK_ROOT MUST BE DEFINED!"
echo "e.g. export NDK_ROOT=$HOME/android-ndk"
exit -1
fi
host_kernel=$(uname -s | tr "[:upper:]" "[:lower:]")
host_arch=$(uname -m)
@arielm
arielm / Android.mk
Created January 29, 2015 21:59
The path for this file should be: mozjs-31.2.0/prebuilt/spidermonkey/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifndef SPIDERMONKEY_SDK_PATH
SPIDERMONKEY_SDK_PATH := $(LOCAL_PATH)/../../..
endif
ifndef SPIDERMONKEY_DIST_PATH
SPIDERMONKEY_DIST_PATH := $(SPIDERMONKEY_SDK_PATH)/js/src/build-android/dist
endif
@arielm
arielm / shared_ptr iteration.cpp
Created February 5, 2014 11:06
Avoiding un-necessary shared_ptr copy when iterating over a container. Paste code into http://www.compileonline.com/compile_cpp11_online.php for testing.
#include <iostream>
#include <string>
#include <vector>
#include <memory>
using namespace std;
int main()
{
vector<shared_ptr<string>> strings;
@arielm
arielm / Android.mk
Last active January 3, 2016 06:59
Building ICU (common) v52.1 for Android. Blueprints from https://github.com/android/platform_external_icu4c/blob/master/common/Android.mk
LOCAL_PATH := $(call my-dir)/..
include $(CLEAR_VARS)
ICU_COMMON_SRC = common
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(ICU_COMMON_SRC)
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cmemory.c
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cstring.c
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cwchar.c