Skip to content

Instantly share code, notes, and snippets.

View hostilefork's full-sized avatar
🌴
I'm Always Somewhere...but I'll Try And Respond

Hostile Fork hostilefork

🌴
I'm Always Somewhere...but I'll Try And Respond
View GitHub Profile
@hostilefork
hostilefork / ideone-map.reb
Last active August 29, 2015 13:57
IDEone language mappings
;-- Language mappings from word! to integer! for IDEone
;--
;-- adapted from: https://ideone.com/faq
;-- (supported languages subsection)
;--
;-- Capture made on 18-Mar-2014 by @HostileFork
[
ada 7 ; gnat-4.6
@hostilefork
hostilefork / red-eval-941.txt
Last active August 29, 2015 14:06
Simple reduce case for Red Issue #941 (with full debug verbosity in interpreter.reds)
;; https://github.com/red/red/issues/941
red>> foo: function [] [a: 10 b: 20 return [a b]]
== func [/local a b][a: 10 b: 20 return [a b]]
red>> reduce foo
;-- skip console boilerplate head code
eval: action/native return type: 2
eval: root loop...
eval: fetching value of type 20
@hostilefork
hostilefork / 1-rebol.reb
Last active August 29, 2015 14:07
Tinker to try and make a Rebol dialected version of the CMake build file WIP for Rebol
Rebmake [
Title: "Rebol Dialected Experiment to represent CMake files"
;; See:
;; http://curecode.org/rebol3/ticket.rsp?id=2177
;; http://browsenpm.org/package.json#dependencies
Needs: [
1.0
cmake 2.8
]
@hostilefork
hostilefork / stackoverflow-2521865
Created October 17, 2014 21:08
how-many-numbers-with-length-n-with-k-digits-d-consecutively
// Test output for
// http://stackoverflow.com/questions/26421865/how-many-numbers-with-length-n-with-k-digits-d-consecutively/26426615
when N = 0 and K = 0 and D = 6:
Fast way gives 0
Slow way gives 0
when N = 0 and K = 1 and D = 6:
Fast way gives 0
Slow way gives 0
@hostilefork
hostilefork / how-many-numbers-with-length-n-with-k-digits-d-consecutively
Last active August 29, 2015 14:07
Test log of "zero-aware" consecutive digit counting algorithm
// "Fast way" results from code by Pham Trung
// ( as of this revision http://stackoverflow.com/revisions/26422842/6 )
// "Slow way" results from the following brute-force C++ code
long FSlowCore(int N, int K, int D, vector<int> & digits) {
if (N == 0) {
auto startPos = find_if(digits.begin(), digits.end(), [](int x) {return x != 0;});
if (startPos != digits.begin())
return 0;
if (search_n(startPos, digits.end(), K, D) != end(digits)) {
// Test for http://stackoverflow.com/questions/8455887/stack-object-qt-signal-and-parameter-as-reference/
#include <iostream>
#include <QCoreApplication>
#include <QTimer>
#include "param.h"
int main(int argc, char *argv[])
{
@hostilefork
hostilefork / const-wrapper-test.cpp
Created July 13, 2012 19:23
Preserving Const-Correctness of an Implementation class when Creating Wrappers
// const-wrapper-test.cpp
//
// For motivation and argumentation, reference:
// http://stackoverflow.com/questions/11167483/deriving-from-a-base-class-whose-instances-reside-in-a-fixed-format-database-m
// http://stackoverflow.com/questions/11219159/make-interchangeable-class-types-via-pointer-casting-only-without-having-to-all
#include <iostream>
#include <cassert>
#include "const-wrapper.h"
@hostilefork
hostilefork / main.cpp
Created July 30, 2012 04:49
Simple default Qt Creator program which generates ridiculous valgrind log
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
@hostilefork
hostilefork / genetic.cpp
Created November 25, 2012 16:01
"Genetic Algorithm" from someone's StackOverflow question
// http://stackoverflow.com/questions/13552057/c-vector-access-violation-when-trying-to-write
#include <iostream>
#include <vector>
using namespace std;
class gen {
public:
int basa_biner;
@hostilefork
hostilefork / r3-cppwarnings-initial
Last active December 9, 2015 23:08
New state after removing literal to non-const char* value assignments, after patching Rebol 3 Open Source to build with bleeding edge G++...with -fpermissive and -fshort-wchar
../src/core/b-boot.c:2917:1: warning: initializer-string for array of chars is too long [-fpermissive]
../src/core/b-init.c: In function ‘void Load_Boot()’:
../src/core/b-init.c:159:33: warning: invalid conversion from ‘void*’ to ‘REBYTE* {aka unsigned char*}’ [-fpermissive]
../src/core/b-init.c: In function ‘void Register_Codec(const REBYTE*, codo)’:
../src/core/b-init.c:704:2: warning: invalid conversion from ‘void*’ to ‘ANYFUNC {aka void (*)(void*)}’ [-fpermissive]
../src/core/b-init.c: In function ‘void Set_Option_String(REBCHR*, REBCNT)’:
../src/core/b-init.c:728:36: warning: invalid conversion from ‘REBCHR* {aka unsigned char*}’ to ‘const char*’ [-fpermissive]
../src/core/b-init.c: In function ‘REBCNT Set_Option_Word(REBCHR*, REBCNT)’:
../src/core/b-init.c:740:7: warning: invalid conversion from ‘REBCHR* {aka unsigned char*}’ to ‘const char*’ [-fpermissive]
../src/core/b-init.c: In function ‘void Init_Main_Args(REBARGS*)’: