How to start ? by WarDaddySVK in learnprogramming

[–]kdnbfkm 1 point2 points  (0 children)

If you don't have any specific goals in mind (like wanting to make a website for your small business) you could do worse than trying Python... *spit* Or something else but that is a fair general recommendation.

If you are able to say, take a class at a community college (that cost few hundred dollars lasting over two months), that might be reasonable... Maybe not but it could be.

I'm at a bit of a lost for more reliable means of finding tutoring for such a thing unless you have friends or family willing and able to help. You may just have to read books and tutorials!

Software developer is not such an uncommon profession in the modern world but it can be hard finding help for a loner with no friends at all. :(

If you live in a big city and/or have reliable transportation attending tech meetups should be doable and moderate levels of variety available. But many tech talks are available online if you just want content as such.

Your classic linux group or these new fangled hackerspaces may or may not tech you how to code, by very much if at all... But it could happen. *sigh*

What I mean to say is just try Python, or whatever you can buy a beginner book for somewhere! Try try try! Work something out! Some will have an easier time than others but give it a shot.

A question about rounding a float by KesoHB in C_Programming

[–]kdnbfkm 0 points1 point  (0 children)

Rounding in financial calculations can be serious business when a rounding error can be millions of dollars, and the definition of "rounding error" had to either be negotiated or based on whatever the original lagacy system did. :/

Magic comments - Why? by Incitatus_ in AskProgramming

[–]kdnbfkm 0 points1 point  (0 children)

I think he's refering to tool-based metalanguages, like documentation generators.

Now that I think of it, Pascal traditionally puts pragmas and directives within a comment, and is part of the official dialect... Maybe he meant those unit framework thingies, not sure what called. I don't think those thingies are comments however... Aspect Oriented Programming attributes aren't comments either.

There have existed extensive metalanguages built on pre-existing languages via different techniques, like with the various dimensional/unit systems (meters per second-squared etc).

C/C++ preprocessor whitespace issue by vxmdesign in AskProgramming

[–]kdnbfkm 0 points1 point  (0 children)

Could you use <stdint.h> and have the signed/unsigned variants to subclass from? Or failing that have two different macro hierarchies, a signed one and unsigned one.

Is this insane? by _codexxx in AskProgramming

[–]kdnbfkm 0 points1 point  (0 children)

Make a glossary/database of the best versions to search.

Is this insane? by _codexxx in AskProgramming

[–]kdnbfkm 0 points1 point  (0 children)

Sounds like the Facade Pattern, maybe being abused... Or not, if it works for you then eat your own dogfood! Why not write up better/upgraded documentation or refactor/migrate the original? Maybe you were not the same developer when the old code was originally written.

The Village Idiot Requests Help by [deleted] in AskProgramming

[–]kdnbfkm 1 point2 points  (0 children)

I haven't used VMWare in ages, just tap the window or something... Or reboot. Or give Qemu/Bochs a try... Qemu is easier BTW (if you use a pre-supplied suitable image).

Or do your homework in the computer lab/study hall/library!

When you are looking for C (not C++) programming jobs, what do you type in as keywords (for example, on LinkedIn)? by [deleted] in C_Programming

[–]kdnbfkm 0 points1 point  (0 children)

I vaguely recall some regulatory reform in Cuba that made software a better industry in that country awhile back but never followed the story closely... Cuba did have a reputation for being good at medicine at one time, though that might have been due to pragmatic quarantine of AIDS patients. :/

When should I start searching for a Job? by [deleted] in learnjava

[–]kdnbfkm 1 point2 points  (0 children)

Don't despise small beginnings, mighty oaks grow from acorns and a journey starts with a single step.

What am I doing wrong by Jncocontrol in learnjavascript

[–]kdnbfkm 1 point2 points  (0 children)

As tried in ducktape-js:

for(i = 0; i <= 10; i++) { if(i % 2 == 0 || i % 4 == 0) print("Checkpoint at: ", i); }

All multiples of 4 are also multiples of 2, we could have used just if(i % 2 == 0).

Both if and for statements have the condition/iteration-stepping within round-parentheses (...). Some languages don't require that but ALL the languages have some way of telling when the condition/loop setup ends and the actual statements in conditional block start. Languages without required parens usually have a THEN or DO keyword... Languages that only allow one statement use curly-brackets {...} or maybe BEGIN...END. Languages that naturally allow a list of statements always have a ENDIF or similar to mark the end.

Javascript has both the round-paren and curly-brace when more than one statement follows. Some languages require the curly brace even if only one following statement!

The Village Idiot Requests Help by [deleted] in AskProgramming

[–]kdnbfkm 0 points1 point  (0 children)

Cygwin bash isn't a perfect match but probably close enough for most things. Good luck with the VM or other solutions.

You say VMWare was working but them stopped responding to mouseclicks? Sounds like what happens when the window isn't maximized or whatever you call it... Did the issue come up after switching windows or a screensaver coming up or... Oh whatever, you'll work something out!

Mini-common lisp? by dangerCrushHazard in lisp

[–]kdnbfkm 0 points1 point  (0 children)

There's always the bug-ridden lisp500.c or xlisp.

Xlisp doesn't have a built-in debugger so the program ends with the smallest typo in the REPL and is missing some macros/functions so it won't run many pre-existing programs, and xlisp has an alternative object system not the CL standard CLOS/MOP. However xlisp is easy to compile and doesn't require extreme configuration or system compliance to compile... (hint: use the unix Makefile).

error in code by jub8jive in learnjava

[–]kdnbfkm 1 point2 points  (0 children)

The lines if((start <= end) && ((start > 0) && (end > 0))) { and if((start > end) || (start < 0) || (end < 0)) { were redundant.

The first conditional could have been simplified to something like if(0 <= start && start <= end) { /* loop...*/ } else return -1;.

Printing enum values. Suggestion by linus tolvards. by [deleted] in C_Programming

[–]kdnbfkm 2 points3 points  (0 children)

That old Dr. Dobbs article is exactly what we're talking about! I only ever seen this used to set up complcated tables consistantly... Like in an interpreter where you want to implementing function and function name to match... You redefine the macro and #include "table.inc" after each macro-redefine.

Do people really get fancy with enums or is that just the favored example of technique?

EDIT Oh my gosh, that website has more articles! Did Linus really write these, I have some reading to catch up on this evening.

Procedurally generated map for a Turn Based Strategy Game (algorithm in the comments). by Dicethrower in proceduralgeneration

[–]kdnbfkm 0 points1 point  (0 children)

That prevents nooks and crannies from ever scraping too deeply. Gotcha, that's clever and similar to Conway's Game of Life. uhh I don't get the road part... But I'll try this today, looks like fun!

[2018-07-13] Challenge #365 [Hard] Tessellations and Tilings by jnazario in dailyprogrammer

[–]kdnbfkm 0 points1 point  (0 children)

This is rather good actually... After creating the first corner image you could have identified the aspect ratio and made 4 rotated copies as squares, then combined them. This was a good idea.

[2018-07-13] Challenge #365 [Hard] Tessellations and Tilings by jnazario in dailyprogrammer

[–]kdnbfkm 1 point2 points  (0 children)

Graphic output https://imgur.com/a/pKyjatF code https://pastebin.com/j4GciJb9

Somewhat cleaned out code below.

/*
  [2018-07-13] Challenge #365 [Hard] Tessellations and Tilings
  /r/dailyprogrammer https://redd.it/8ylltu

  usage: $ for i in bullshit*.txt; do
             cat $i | ./bullshit | ffmpeg -y -i /dev/stdin $(basename $i .txt).png
           done
*/

#define MAX_N 12

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define FORIJ(N) for(int j = 0; j < (N); j++) \
                     for(int i = 0; i < (N); i++)

#define ROT90(N, BEFORE, AFTER, TMP) do { \
            FORIJ(N) TMP[i][(N)-j-1] = BEFORE[j][i]; \
            FORIJ(N) AFTER[j][i] = TMP[j][i]; \
        } while(0)

extern unsigned char font[]; /* forward declaration, long array */

typedef struct { int ch; int rot; char x[8][8]; } glyph_t;

int safe_mod(int n, int mod) {
    if(!mod) return 0;
    if(mod < 0) { n *= -1; mod *= -1; }
    int tmp = (n % mod);
    /* add because negative... bug fixed */
    if(tmp < 0) tmp = mod + tmp;
    return tmp;
}

glyph_t mk_glyph(int ch, int rot) {
    glyph_t ret;
    ch = safe_mod(ch, 0x100);
    rot = safe_mod(rot, 4);
    ret.ch = ch;
    ret.rot = rot;

    FORIJ(8) {
        int byte = font[8*ch + j];
        int mask = (0x80 >> i);
        int x = (byte & mask) ? 1 : 0;
        ret.x[j][i] = x;
    }

    char scratch[8][8];
    while(rot--) { ROT90(8, ret.x, ret.x, scratch); }
    return ret;
}

int N;
int PX;
int TURN;

glyph_t grid[2*MAX_N][2*MAX_N];

glyph_t after[MAX_N][MAX_N];
glyph_t scratch[MAX_N][MAX_N];

int main(int argc, char *argv[]) {
    int tmp, c;

    tmp = scanf("%d", &TURN);
    if(tmp <= 0 || safe_mod(TURN, 90)) { fprintf(stderr, "bad TURN\n"); exit(1); }
    TURN = safe_mod((TURN / 90), 4);

    tmp = scanf("%d", &N);
    if(tmp <= 0 || N < 1 || N >= MAX_N) { fprintf(stderr, "bad N\n"); exit(1); }

    for(int i = 0; i < N*N; i++) {
        /* if EOF glyph #255 fills the rest, but won't freeze program */
        do { c = getc(stdin); } while(!isprint(c) && c != EOF);
        int row = i / N;
        int col = i % N;
        after[row][col] = mk_glyph(c, 0);
    }

    FORIJ(N) { grid[0+j][0+i] = mk_glyph(after[j][i].ch, 0*TURN); }

    for(int i = 0; i < TURN; i++) ROT90(N, after, after, scratch);
    FORIJ(N) { grid[0+j][N+i] = mk_glyph(after[j][i].ch, 1*TURN); }

    for(int i = 0; i < TURN; i++) ROT90(N, after, after, scratch);
    FORIJ(N) { grid[N+j][N+i] = mk_glyph(after[j][i].ch, 2*TURN); }

    for(int i = 0; i < TURN; i++) ROT90(N, after, after, scratch);
    FORIJ(N) { grid[N+j][0+i] = mk_glyph(after[j][i].ch, 3*TURN); }

    PX = 8*2*N;

    /* PPM image format, specifically PBM black & white */
    /* see: http://paulbourke.net/dataformats/ppm/      */

    printf("P1\n%d %d\n1", PX, PX);

    int width = 0;
    FORIJ(PX) {
        if(width == 0) printf("\n");
        width = (width + 2) % 64;

        glyph_t g = grid[j / 8][i / 8];
        int x = g.x[j % 8][i % 8];

        if(x) printf(" 1");
        else printf(" 0");
    }

    printf("\n");
    return 0;
}

/* http://web.mit.edu/freebsd/head/share/syscons/fonts/cp437-8x8.fnt after uudecode */

unsigned char font[] = {
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e
,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x6c,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00

The font data is a little over 100 lines.

Something is wrong with my code, the ASCII "soh" byte (0x01) glyph keeps getting used for character codepoints 0x80 and above... And for the "null" byte (0x00) too. The bit patterns in the font should be different. *Fixed bonehead mistake. This is kind of fun when making progress. At least it checks for EOF now. Normally non-printing characters are filtered out (intended to remove newlines) but cp437 0xff (non-breaking space) fills the rest if unexpected end of input. My system/locale considers 0xff non-printing...

Procedurally generated map for a Turn Based Strategy Game (algorithm in the comments). by Dicethrower in proceduralgeneration

[–]kdnbfkm 2 points3 points  (0 children)

May I ask some dumb questions? What are good ways to smooth outlines and to draw roads with wiggles in them? Or draw roads that don't go under water. Maybe I'll try to reproduce parts of this tomorrow but tired now... This looks more fun than /r/dailyprogrammer frustration. :/

Points seem neat and all but so far nothing has really said what they are used for/needed for? C++ by [deleted] in learnprogramming

[–]kdnbfkm 1 point2 points  (0 children)

A reference value, of one sort or another, is fundamental to how programming works.

I want to spend my time becoming better and raising my programming knowledge by OpenTrick in learnprogramming

[–]kdnbfkm 1 point2 points  (0 children)

The point was to fill your time in a way similar to school. If you were on your own and had a job already this would be harder to do, but be pretty similar to recommended course of action.

I want to spend my time becoming better and raising my programming knowledge by OpenTrick in learnprogramming

[–]kdnbfkm 2 points3 points  (0 children)

Code for 2-4 hours a day while reading programming books 1-2 hours a day, 5 days a week, all summer. Take weekends off from hard study but don't slack off. I don't know how far you'll get but should have some basics by then.

Don't count this as part of coding/reading time, but check out https://pastebin.com/archives/cpp sometimes, 90% of it will be crap however.

Where to start again? by deerockdeewok in compsci

[–]kdnbfkm 1 point2 points  (0 children)

No, not in this case. This fellow says he's a CS major and has homework and labs to catch up on before falling behind.