Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Star War Sex Parrot
Oct 2, 2003

Van Kraken posted:

quick update on emulator:

in swift, switch/case does not have automatic fallthrough.
in the metal shading language, switch/case DOES have automatic fallthrough.

this explains the last 2 hours of my life.

:suicide:
Got this on a public repo?

Adbot
ADBOT LOVES YOU

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Luigi Thirty posted:

what the hell were you emulating that used a MIPS processor :pwn:

n64 was mips

Luigi Thirty
Apr 30, 2006

Emergency confection port.

cis autodrag posted:

n64 was mips

i know lots of things were mips! it's just they're all mid-90s 3d poo poo that's hard to emulate for various reasons

Van Kraken
Feb 13, 2012

Star War Sex Parrot posted:

Got this on a public repo?

https://github.com/colevk/GameBoy

it's currently configured for xcode 9 beta and swift 4, though, so if you don't have those i'm not sure how much effort it would be to convert it back.

Mr SuperAwesome
Apr 6, 2011

im from the bad post police, and i'm afraid i have bad news

Lutha Mahtin posted:

i think it's best to start out with the questions "who is my audience", "what is the point of this training supposed to be", and "what are my constraints" (i.e. time and other resources). it sounds like you have some flexibility in designing the class; imo this is good and might be a big key to your success

for your audience, if it's going to be people at your org who mostly don't have programming/cyberwizard knowledge, i would suggest to design your class at their level. you say there are some JS devs in the class who (presumably) know more, but imo it's better for the couple of more-technical people to be bored with stuff they already know, vs. trying to sprinkle in advanced concepts for them and confusing the heck out of your newbies

for the point of the training, is there one? did you volunteer for this, did some higher-up put you on it, is there some specific goal or set of criteria you're supposed to be working towards? my uninformed guess is that you probably have a goal like "explain to these people what my department/team does" or "get people more interested in this side of our operation" or something like that

for time and resources, imo this is one of the key things about giving a speech/presentation/class. it is very easy to cram too much stuff into a presentation. i would be careful about your plan to explain "programming, backend, and our tech stack" in one hour to a bunch of nontechnical people. lecturing for an hour on random computer science topics and tech buzzwords has a very good chance to just make your colleagues' eyes glaze over, and even if they do care, spending three minutes giving a super condensed summary of big-O notation or whatever probably won't stick with them or be useful to them. the other thing about resources is "do i have access to computers or other things i may want to use as teaching aids". you want to have this stuff set up and ready to go so that you aren't wasting time janitoring computers during your training. one other resource i would keep in mind is people: if you do something like code academy, you WILL end up running around to help people during the activity, so if your class will have more than a few people, this kind of activity would benefit a lot from having technical coworkers who can help during that portion of it

i think your idea of having people do an activity is better than just lecturing, but i would still keep in mind my three bullet points here. code academy is great, but ask yourself: will my audience learn anything, or even give a crap? if they will learn something, is it going to satisfy what we're actually trying to do with this training? if yes, do we have the resources for this to run smoothly, and enough time that they will learn what we want them to/learn enough? (obviously you can't make people give craps about things, but imo it helps to at least consider the question)

my final advice would be: try to make it fun, or at least mildly interesting. an example here would be one of the CS professors at my college, and the activity he would do during the first class period when he taught the networking course. this class was one of the lower level classes in the department, and it was a requirement for CS, MIS, and maybe was an elective for other things, so you had a mix of people from "i am totally already dedicated to being a cs major" to "i'm not sure yet" and "i have to take this nerd class omg". the activity he did was to give every student a sheet of paper that was folded in half. then he would explain that on the inside of the paper there was a set of instructions, and when he said "go" you were to unfold the paper and follow them. then he says "go" and you unfold the paper, and it says "you are number X. everyone else has a number, too. you have a list of instructions below that you need to follow". and the instructions were like "give the message 'hello' to number Y" or "if you get the message 'the job is done' from number Z, give the message 'continue' to number A". what happens of course is that the room at first explodes into people yelling, but then usually what happens is that everyone organizes themselves into some system of message passing. then when the class is done, the professor would put on his aviator shades and say "imagine four computer science students on the edge of their seats..."

this is a v. good post, thanks.

i need to figure out what the actual point of this is first before i can figure out the rest, i guess

FlapYoJacks
Feb 12, 2009
I just wanted to say, CLion is good.

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Sapozhnik posted:

but again, the actual music is hardware-encrypted and afaik nobody's figured out the fpga/cpld/whatever that sits between the cpu and the mp3 decoder chip. and if capcom cps3 is anything to go by then there were a lot of surprisingly competent bored amateur cryptographers working at japanese game companies around the turn of the century.

weren't they just xor tables, though?

Notorious b.s.d.
Jan 25, 2003

by Reene

cinci zoo sniper posted:

how's the structure suited for ad hoc analytics by people used to generic row databases?

column-oriented databases and olap poo poo in general assumes you are gonna spend most of your time doing complete table scans. it's "column-oriented" because it stores all the data for a given column contiguously, in order to be easily slurped up by a single read on a lovely spinny disk

ordinary RDBMSes store data in rows because they expect you to have a schema designed for your common query patterns, with indices to support the queries. they want to be able to cherry-pick specific rows with a minimum number of seeks, and the index will tell them where the "answers" are for a given "question."

with OLAP workloads you don't know what the common queries will be, so you can't design the schema or create indices ahead of time!

--

map/reduce and hive and friends are the logical furthest extreme of a column-oriented database. every query will read the entire database and process all data. there's often no indexing, schema, or optimization whatsoever

downside: simple queries can take literally 60 seconds to execute
upside: extremely complex queries still only take 60 seconds to execute

you have a very high floor and a very low ceiling on execution time. sucks for rendering a web page in real time, rules for answering analytics questions for your BI team

Notorious b.s.d.
Jan 25, 2003

by Reene

CPColin posted:

Apparently one of the teams at my new job uses COBOL.NET, which is bad enough, but they also have functionality that's basically a big string containing old COBOL code that's passed to an interpreter. :psyduck:

I found this out when they explained why they didn't need to talk to the TFS guy about adding automated testing to the CI configuration. They can't test output from the interpreter!

migrating your legacy COBOL code to a modern platform is good and cool

failing to test your legacy code because the harness would be more complicated than just pointing nunit at it is a big lovely ball of failure and sadness, though. fuckin fix that, you assholes

CPColin
Sep 9, 2003

Big ol' smile.
Yeah, I was thinking, "There's really no output from this legacy code that you can check with an automated process? At all?" but I didn't want to be That Guy who comes in on his seventh day at a new job and tells everybody they're doing it wrong.

cinci zoo sniper
Mar 15, 2013




Notorious b.s.d. posted:

column-oriented databases and olap poo poo in general assumes you are gonna spend most of your time doing complete table scans. it's "column-oriented" because it stores all the data for a given column contiguously, in order to be easily slurped up by a single read on a lovely spinny disk

ordinary RDBMSes store data in rows because they expect you to have a schema designed for your common query patterns, with indices to support the queries. they want to be able to cherry-pick specific rows with a minimum number of seeks, and the index will tell them where the "answers" are for a given "question."

with OLAP workloads you don't know what the common queries will be, so you can't design the schema or create indices ahead of time!

--

map/reduce and hive and friends are the logical furthest extreme of a column-oriented database. every query will read the entire database and process all data. there's often no indexing, schema, or optimization whatsoever

downside: simple queries can take literally 60 seconds to execute
upside: extremely complex queries still only take 60 seconds to execute

you have a very high floor and a very low ceiling on execution time. sucks for rendering a web page in real time, rules for answering analytics questions for your BI team

hmm, this is something. i don't generally make complex queries, but consistency sounds good enough. the latency thing otoh is something to consider, given that we may intend to render some analytics to a web solution in real time-ish fashion. either way this and previous posts about my question should be good enough for the rnd day. ill probably return on thursday with more stupid columnar db questions

Sapozhnik
Jan 2, 2005

Nap Ghost

CRIP EATIN BREAD posted:

weren't they just xor tables, though?

XOR tables aren't a crack, they're a way to "legally" distribute the decrypted data (by distributing them as a set of bit flips you apply to the illegally-distributed ciphertext).

I can create XOR tables that "decrypt" any sufficiently-large file to hello.jpg for all that matters.

Star War Sex Parrot
Oct 2, 2003

Van Kraken posted:

https://github.com/colevk/GameBoy

it's currently configured for xcode 9 beta and swift 4, though, so if you don't have those i'm not sure how much effort it would be to convert it back.
Thanks! I just wanted to take a look at your approach

Notorious b.s.d.
Jan 25, 2003

by Reene

cinci zoo sniper posted:

hmm, this is something. i don't generally make complex queries, but consistency sounds good enough. the latency thing otoh is something to consider, given that we may intend to render some analytics to a web solution in real time-ish fashion. either way this and previous posts about my question should be good enough for the rnd day. ill probably return on thursday with more stupid columnar db questions

it's not about the complexity of the query, it's about the predictability of the query. even a simple select will murder RDBMS performance if the schema + indices were not designed for that particular query.

if you are going to make a similar pattern of complex queries over and over, you can design an appropriate schema for your RDBMS to handle the load.

if you don't know what the query pattern will be ahead of time, you are in OLAP-land, and that is a really bad place to be.

cinci zoo sniper
Mar 15, 2013




Notorious b.s.d. posted:

it's not about the complexity of the query, it's about the predictability of the query. even a simple select will murder RDBMS performance if the schema + indices were not designed for that particular query.

if you are going to make a similar pattern of complex queries over and over, you can design an appropriate schema for your RDBMS to handle the load.

if you don't know what the query pattern will be ahead of time, you are in OLAP-land, and that is a really bad place to be.

hm, this makes sense and kinda sounds where we are, even tho query pattern could be designed ahead of time (given time which we dont, as always)

MrMoo
Sep 14, 2000

I've spent most of today working out how to scale Snapchat's company logo in JavaScript :negative:

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

HoboMan posted:

the only real bug is it crashes if a network call fails. it's a real important bug, but hopefully fixing it won't take much more than figuring out where to put the try-catches

is the network call being made on the UI thread? if your previous person didn't understand try/catch, this is something i would check for

also, check out OkHttp if you want an easy-mode way to do http networking on android

Luigi Thirty
Apr 30, 2006

Emergency confection port.

well it took like 4 hours but I can rotate a shape around the origin and draw it on the screen :toot:

...in 320x200 1bpp graphics mode
...using the FPU library in AmigaOS

VikingofRock
Aug 24, 2008




So I'm trying to write a C++ function which takes a mapping of std::string -> <some stringified value>, and a list of std::string keys, and which returns an std::tuple of de-stringified values. The reason I would want to write such a thing is that I'm working with files which are basically a set of lines which look like key: stringified value. Like so:
pre:
height: 5.5
weight: 130
poops: nutty
Why not use a CSV? Legacy code! Anyways, I have a function already written which generates the above string -> string mapping given these files, and I'd like to make a function that lets you get many fields from these files simultaneously. So you can do:

C++ code:
struct Person {
    double height;
    int weight;
    std::string poops;
};

Person person;
std::tie(person.height, person.weight, person.poops) =
    cache.get_many("height", "weight", "poops");
So far this is what I've got:

C++ code:
// forward declaration
template <typename ...Ts, typename ...Keys> 
std::tuple<Ts...> read_all_(
    const Mapping& map,
    Keys... keys
);

// recursive case
template <typename T, typename ...Ts, typename Key, typename ...Keys>
std::tuple<T, Ts...> read_all_(
    const Mapping& map,
    Key key,
    Keys... rest)
{
    return std::tuple_cat(
        std::make_tuple(boost::lexical_cast<T, std::string>(map.at(key))),
        read_all(map, rest...)
    );
}

// base case
std::tuple<> read_all_(const Mapping& _) {
    return std::make_tuple();
}

// public wrapper function: 
template <typename ...Ts, typename ...Keys>
std::tuple<Ts...> get_many(Keys... keys) {
    auto map = parse_();
    return read_all_(map, keys...);
}



Right now when I try to use that as above, I'm getting the following error():
pre:
test_file_cache.cpp:59:23: error: no viable overloaded '='
    std::tie(person.height, person.weight, person.poops) =
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:501:29: note:
      candidate function (the implicit move assignment operator) not viable: no
      known conversion from 'tuple<(no argument), (no argument), (no
      argument)>' to 'tuple<double &, int &, std::__1::basic_string<char>
      &>' for 1st argument
class _LIBCPP_TYPE_VIS_ONLY tuple
                            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:501:29: note:
      candidate function (the implicit copy assignment operator) not viable: no
      known conversion from 'tuple<(no argument), (no argument), (no
      argument)>' to 'const tuple<double &, int &,
      std::__1::basic_string<char> &>' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:693:26: note:
      candidate template ignored: disabled by 'enable_if' [with _Tuple =
      std::__1::tuple<>]
                         __tuple_assignable<_Tuple, tuple>::value
                         ^
I'm pretty confused on this, so any help / insight that anyone wants to offer would be greatly appreciated!

edit: added full error

edit 2: got it working! See post below.

VikingofRock fucked around with this message at 03:44 on Aug 16, 2017

redleader
Aug 18, 2005

Engage according to operational parameters
lol if you don't do literally everything you can in the db. just lol

VikingofRock
Aug 24, 2008




Woohoo, I got it working!

C++ code:
// base case
template <typename ...Ts, typename ...Keys> 
typename std::enable_if<sizeof...(Ts) == 0 && sizeof...(Keys) == 0,
                        std::tuple<Ts...>>::type
read_all_(const Mapping&, Keys...) {
    return std::make_tuple();
}

// recursive case
template <typename T, typename ...Ts, typename Key, typename ...Keys>
std::tuple<T, Ts...> read_all_(
    const Mapping& map,
    Key key,
    Keys... rest)
{
    return std::tuple_cat(
        std::make_tuple(boost::lexical_cast<T>(map.at(key))),
        read_all_<Ts...>(map, rest...)
    );
}

// public wrapper function
template <typename ...Ts, typename ...Keys>
std::tuple<Ts...> get_many(Keys... keys) {
    auto map = parse_();
    return read_all_<Ts...>(map, keys...);
}

// gotta call it like this:
std::tie(person.height, person.weight, person.poops) =
    cache.get_many<double, int, std::string>("height", "weight", "poops");

It would be preferable if I could get this to type deduce that it should call the <double, int, string> version, but oh well this is fine for now.

e: formatting

VikingofRock fucked around with this message at 03:46 on Aug 16, 2017

qhat
Jul 6, 2015


goddamn lua is a loving lovely language

qhat
Jul 6, 2015


so i'm collaborating with a friend to produce a dumb video game and i've essentially been forced to code it using love2d, an otherwise fine API but for lua, which is by far one of the worst programming language i've ever experienced. i've been using it a couple of weeks and i can say it honestly hasn't grown on me.

gonadic io
Feb 16, 2011

>>=
Why do you need more than one number type? Numbers are numbers

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Lua 5 runs on my Amiga 2000 so it is the only language I use for literally anything.

gonadic io
Feb 16, 2011

>>=
Number of elements in a table is not easy to get and the result depends on how you do this (or what you mean by "length"). This is probably not surprising, given how powerful tables are in Lua and the fact that they support flexible indexing (by numbers and any other Lua type except nil). Tables in Lua have two parts: an "array/vector" part (generated with t = {1, 2, 3}) and a "hash" part (generated with t = {a = "foo", ["b"] = 2}); the two can be flexibly combined. #table returns the length of the shortest "array/vector" part (without any gaps) and table.maxn(t) returns the longest "array/vector" part (this function is removed in Lua 5.2). The "hash" part doesn't have a defined length. Both parts can be iterated over using the pairs method, which allows you to count the number of elements in them. However, print(#{1, 2, nil, 3}) prints 4 and not 2 as one may expect, whereas print(#{1, 2, nil, 3, nil}) prints 2. I'm sure there is a good reasonable explanation for this, but for now it is in the "ugly" bucket. [Updated 11/17/2012] As FireFly noted in the comments, in Lua 5.2 the length operator is only defined for tables that don't have holes in them.

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

Number of elements in a table is not easy to get and the result depends on how you do this (or what you mean by "length"). This is probably not surprising, given how powerful tables are in Lua and the fact that they support flexible indexing (by numbers and any other Lua type except nil). Tables in Lua have two parts: an "array/vector" part (generated with t = {1, 2, 3}) and a "hash" part (generated with t = {a = "foo", ["b"] = 2}); the two can be flexibly combined. #table returns the length of the shortest "array/vector" part (without any gaps) and table.maxn(t) returns the longest "array/vector" part (this function is removed in Lua 5.2). The "hash" part doesn't have a defined length. Both parts can be iterated over using the pairs method, which allows you to count the number of elements in them. However, print(#{1, 2, nil, 3}) prints 4 and not 2 as one may expect, whereas print(#{1, 2, nil, 3, nil}) prints 2. I'm sure there is a good reasonable explanation for this, but for now it is in the "ugly" bucket. [Updated 11/17/2012] As FireFly noted in the comments, in Lua 5.2 the length operator is only defined for tables that don't have holes in them.

what the gently caress did i just read

netcat
Apr 29, 2008
lua is incredibly bad and unpleasant to code in. I might even say it's worse than javascript. it is very easy to embed though so I end up using it quite a lot anyway

cinci zoo sniper
Mar 15, 2013




netcat posted:

lua is incredibly bad and unpleasant to code in. I might even say it's worse than javascript. it is very easy to embed though so I end up using it quite a lot anyway

explains lua in wow and garrys mod

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
Lua for whatever reason reminds me of the Userland Frontier language and environment

it was a hierarchical database with code in it, where database locations and variables and functions etc were all kind of interchangeable (sound familiar, mmmm?)

except of course the language, being designed in the late 1980s, was actually superficially C-like

here, have a look at all its System 7-esque weirdness

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

neat

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

redleader posted:

lol if you don't do literally everything you can in the db. just lol

so you're a fan of seeding a table with entropy and reading sequential rows as a RNG?

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

lua is... ok

HoboMan
Nov 4, 2010

if the choice was between making 2 db calls and making 1 but putting some business logic in the db we have gone with the putting logic in the db every time.
would not recommend

qhat
Jul 6, 2015


For some reason everything in lua has to be different purely to be different. Not equals operator is != Right? Wrong. It's ~=. So ~ must be the not operator. Wrong again, 'not' is the not operator. Props to anyone who can tell me how to inherit in lua without having to Google it. Don't even get me started on arrays being 1-indexed.

qhat fucked around with this message at 17:16 on Aug 16, 2017

Pollyzoid
Nov 2, 2010

GRUUAGH you say?

qhat posted:

Props to anyone who can tell me how to inherit in lua without having to Google it.

lua has no classes so "inherit" is a bit weird. i assume you mean metatable fuckery like this

Lua code:
local baz = {}
baz.__index = baz

function baz:bar()
    print(self.a)
end

local foo = { a = "fart" }
setmetatable(foo, baz)
foo:bar() -- accessing a nonexistent value in a table uses its metatable's __index
-- roughly equivalent to
baz.bar(foo)

Pollyzoid fucked around with this message at 20:27 on Aug 16, 2017

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
lua is cool because of how tiny the interpreter is, and how easy it is to bend it to your will.

i have a ton of devices in the field (vehicle/asset tracking) that run lua with fake threads to provide services on a platform with very little power.

There Will Be Penalty
May 18, 2002

Makes a great pet!
use lovely javascript if you need a lovely embedded language

https://docs.cesanta.com/v7/master/

i don't know about threading though

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

lua is actually better than javascript, which is impressive

Adbot
ADBOT LOVES YOU

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

lua inheritance is still far better than javascript prototyping

  • Locked thread