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.
 
  • Post
  • Reply
DoctorOozy
Jun 22, 2013

Like you get in packing paper?

mystes posted:

A lot of antivirus programs will just flag all exes using "packers" (tools which compress exe files and then have a loader which decompresses them in memory)

I assume it is something like this rather than my system is actually compromised. But how do I get past this being (as Killhour correctly said) at the level of an undergrad CS project. If this is the case I find it infuriating I cant share my poo poo projects with interested friends.

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

DoctorOozy posted:

I assume it is something like this rather than my system is actually compromised. But how do I get past this being (as Killhour correctly said) at the level of an undergrad CS project. If this is the case I find it infuriating I cant share my poo poo projects with interested friends lol.
Have you tried to package anything else in python as an exe file using the same tool and seen if it gets flagged? If it's just the aes part then I guess just don't distribute that particular program as an exe file? If it's just the packaging tool in general then try a different one?

But legitimate programs get flagged by antivirus programs all the time. If it's only McAfee you could just ignore it but if it's microsoft and you really need to distribute it as an exe you will probably need to figure out how to change it so it doesn't get flagged

DoctorOozy
Jun 22, 2013

Like you get in packing paper?

mystes posted:

Have you tried to package anything else in python as an exe file using the same tool and seen if it gets flagged? If it's just the aes part then I guess just don't distribute that particular program as an exe file? If it's just the packaging tool in general then try a different one?

Yes I have done loads of things, picture viewers, text analyzers, data management etc.. the only significant change here is this one contains encryption.

I think ill change the encryption module and see if it still happens. Maybe its a library issue.

BTW thanks everyone for your suggestions :D its been a while since I used SA and again I realize how stupid that's been.

EDIT: doesn't help. I'm going to try different exe packaging programs

DoctorOozy fucked around with this message at 01:01 on Aug 30, 2023

KillHour
Oct 28, 2007


DoctorOozy posted:

But how do I get past this being (as Killhour correctly said) at the level of an undergrad CS project.

This is kind of annoying, but a lot of it is that Python isn't really made for making distributable executables, so pretty much anything you make with Python that way is going to fall into that bucket.

DoctorOozy
Jun 22, 2013

Like you get in packing paper?
Ok I solved it so ill explain incase it helps/is interesting.

When I used AES (Advanced Encryption Standard) encryption the exe was flagged by Google Download (from Drive) and MS security as a virus/malicious. This was using PyInstaller.

I tried Freeze and it worked but was not a single package, i had DLLs etc all over.

When I changed to ChaCha20 cypher it seems to work fine and nether google or MS flag it.

mystes
May 31, 2006

DoctorOozy posted:

When I changed to ChaCha20 cypher it seems to work fine and nether google or MS flag it.
Heuristic virus detection is really dumb.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

DoctorOozy posted:

Ok I solved it so ill explain incase it helps/is interesting.

When I used AES (Advanced Encryption Standard) encryption the exe was flagged by Google Download (from Drive) and MS security as a virus/malicious. This was using PyInstaller.

I tried Freeze and it worked but was not a single package, i had DLLs etc all over.

When I changed to ChaCha20 cypher it seems to work fine and nether google or MS flag it.

Added to Shadow_brokers_notes.txt

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

DoctorOozy posted:

Ok I solved it so ill explain incase it helps/is interesting.

When I used AES (Advanced Encryption Standard) encryption the exe was flagged by Google Download (from Drive) and MS security as a virus/malicious. This was using PyInstaller.

I tried Freeze and it worked but was not a single package, i had DLLs etc all over.

When I changed to ChaCha20 cypher it seems to work fine and nether google or MS flag it.

This isn't surprising, since using ChaCha20 made your program Real Smooth, and it was easily able to slide past the virus detection.

Shaocaholica
Oct 29, 2002

Fig. 5E
With the latest Xcode tools do you have to manually optimize for x86 builds or it’s just automagic arm and x86 from the same code?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Shaocaholica posted:

With the latest Xcode tools do you have to manually optimize for x86 builds or it’s just automagic arm and x86 from the same code?

I'm not 100% sure what you mean, but the same code works as input for both architectures and the optimization setting for a given configuration will apply to each architecture you build for. By default, that's to optimize only in Release builds. Debug won't optimize, and I think also only builds the "current" architecture.

Shaocaholica
Oct 29, 2002

Fig. 5E
Sorry I was vague. I haven't coded in forever. I don't even know what (code side) architecture specific optimizations even look like and if they are even 'a thing' when compiling for Mac. Not optimizations the compiler does but what you can do in the source.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Shaocaholica posted:

Sorry I was vague. I haven't coded in forever. I don't even know what (code side) architecture specific optimizations even look like and if they are even 'a thing' when compiling for Mac. Not optimizations the compiler does but what you can do in the source.

It’s just automatic arm/x86 you don’t need to write specific code per platform (generally)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
I have a feeling you’re thinking of something specific and not finding the right words for it.

nielsm
Jun 1, 2009



Are you maybe thinking of SIMD code? (Single Instruction Multiple Data) That's for example SSE and AVX on x86, and Neon on ARM.
It's generally not automatic, no, except for some very specific patterns the compiler might recognize. If you want your code to take advantage of those CPU features then you have to write CPU-specific code. You can do it by writing the routines in assembly and link in, but it's more common and convenient to use the intrinsics offered by the compiler.

darthbob88
Oct 13, 2011

YOSPOS
How would you solve a problem like this in a program? I've considered brute forcing every possibility, but that's 16! or about 20 trillion possibilities. None of the constraint solver libraries I can find are quite compatible with 2D arrays or the strings I'd need to enforce a uniqueness constraint between "I" and "1". Backtracking is probably the best option, but I've mostly forgotten how to do that and wasn't entirely comfortable with it anyhow.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Write it as a zero-one integer program with a constant objective function and feed that into a standard solver.

ultrafilter fucked around with this message at 17:53 on Sep 9, 2023

darthbob88
Oct 13, 2011

YOSPOS

ultrafilter posted:

Write it as a zero-one integer program with a constant objective function and feed that into a standard solver.
How do I encode something like the adjacency requirements in that objective function? That's why I'm trying to do it with a 2D array.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
You can encode this using binary decision variables and penalty terms. Main idea would be to subtract a big number if the items are not adjacent in the objective function.

Variables:

1. Let xij be a binary decision variable that equals 1 if an item is placed on grid cell (i, j), and 0 otherwise.
2. For every pair of cells (i,j) and (k,l), define a binary decision variable yijkl that equals 1 if an item from cell (i,j) is adjacent to an item in cell (k,l).

Adjacency on a Grid:

1. For cells (i,j) and (k,l) to be adjacent horizontally, either k = i and l = j+1 or k = i and l = j-1.
2. For cells (i,j) and (k,l) to be adjacent vertically, either k = i+1 and l = j or k = i-1 and l = j.
3. For diagonal adjacency, either k = i+1 and l = j+1, or k = i+1 and l = j-1, or k = i-1 and l = j+1, or k = i-1 and l = j-1.

Objective Function Encoding:

1. To enforce adjacency in the objective function, introduce a penalty term for violations. Use a large constant M to penalize non-adjacency when cells are supposed to be adjacent.
2. For every pair of cells you'll have a term like: -M × (xij × xkl - yijkl)
3. You'll sum up all such terms for every pair of cells to create your penalty.

Constraints:

1. Ensure yijkl can only be 1 if both xij and xkl are 1. This can be modeled as:
yijkl ≤ xij
yijkl ≤ xkl

2. If yijkl is 1, then (i,j) and (k,l) must be adjacent. This means having constraints to enforce that only valid (k,l) values are used given a specific (i,j) value. Depending on the grid size, this can mean a large number of constraints.

Objective Function:
Objective = Other Criteria - ∑(i,j,k,l) in required pairs M × (xij × xkl - yijkl)

Doktor Avalanche
Dec 30, 2008

i think i'll stick to making CRUD apps

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

darthbob88 posted:

How would you solve a problem like this in a program?

This is a great use-case for an SMT solver like Z3. Long story short is that SMT solvers are a bit like boolean SAT solvers on steroids: they use a SAT solver under the hood but let you encode richer datatypes than just bools.

I wrote the first few constraints here to get you started using the excellent Z3 solver:

Python code:
#!/usr/bin/env python3
#
# Usage:
# $ python3 -m venv ./venv
# $ source ./venv/bin/activate
# (venv) $ pip install z3-solver
# (venv) $ python griddle.py

from typing import Tuple

import itertools
import sys
import z3

solver = z3.Solver()

## Here we begin our constraint generation functions.  I wrote a few to
## get you started; you get to do the fun parts and encode the rest!

def is_arabic(i: z3.Int):
    " An arabic numeral is on [0, 10)."
    return z3.And(i >= 0, i < 9)

def is_roman(i: z3.Int):
    " A roman numeral is something weird!  Who can remember what these are anyway"
    return z3.Or(i == 10, i == 100, i == 500, i == 1000)

def valid_val(i: z3.Int):
    return z3.Or(is_arabic(i), is_roman(i))

def both_rom_and_ara(cells: list[z3.Int]):
    """ The given Ints must be a mix of roman and arabic values (ie. they cannot
    be all roman numerals and cannot be all arabic numerals) (rule 1)"""
    not_all_arabic = z3.Not(z3.And([is_arabic(i) for i in cells]))
    not_all_roman = z3.Not(z3.And([is_roman(i) for i in cells]))
    return z3.And(not_all_arabic, not_all_roman)

def corners_are_row_3(board):
    " The corners of the board must sum to the same value as the third row."
    corners = [board[(0,0)], board[(0,3)], board[(3,0)], board[(3,3)]]
    row_3 = [board[2, j] for j in range(4)]
    return z3.Sum(corners) == z3.Sum(row_3)

## 

def symbolic_int(i, j) -> z3.Int:
    sym = z3.Int(str(i) + "," + str(j))
    return sym

def print_cell(i: int):
    " Pretty-prints a given cell as either a roman numeral or a digit. "
    romans = {10: "X", 50: "L", 100: "C", 500: "D", 1000: "M"}
    if i in romans:
        sys.stdout.write(romans[i])
    else:
        sys.stdout.write(str(i))

def print_model(b, m: z3.Model):
    """ Given an assignment of values that we got back from z3, print them
    out in tabular form. """
    for i in range(0, 4):
        for j in range(0, 4):
            print_cell(m[b[i,j]].as_long())
            sys.stdout.write(" ")
        sys.stdout.write("\n")

if __name__ == "__main__":
    # The board maps indices on [0,4) to a symbolic number that z3 will solve for.
    board: dict[Tuple[int, int], z3.Int] = {}

    # cell constraints
    for i,j in itertools.product(range(4), range(4)):
        s = symbolic_int(i,j)
        solver.add(valid_val(s))
        board[(i,j)] = s

    # Row and column constraints
    for i in range(4):
        cells = [board[i,j] for j in range(4)]
        solver.add(both_rom_and_ara(cells))
    for j in range(4):
        cells = [board[i,j] for i in range(4)]
        solver.add(both_rom_and_ara(cells))

    # Diagonal constraints
    cells = [board[i,i] for i in range(4)]
    solver.add(both_rom_and_ara(cells))
    cells = [board[3-i,i] for i in range(4)]
    solver.add(both_rom_and_ara(cells))

    # Other constraints
    solver.add(corners_are_row_3(board))
    # TODO: You do the rest!

    # Now hand all the constraints to z3 and check that they are satisfiable,
    # and then print out the assignments that the solver comes up with!
    assert(solver.check() == z3.sat)
    print_model(board, solver.model())
Most of the constraints I've left to you to implement, but hopefully you can see how from the ones I did implement. We can already see that z3 is finding solutions for the ones I did implement: For instance, every row, column, and diagonal has a mix of Roman and Arabic digits, and, the sum of the corners (8 + D=500 + 8 + D=500) equals the sum of row 3 (M=1000 + 0 + X=10 + 6).

code:
(venv) $ python3 griddle.py
8 M 0 D
0 0 0 M
M 0 X 6
D 0 0 8
(venv) $

darthbob88
Oct 13, 2011

YOSPOS

Bruegels Fuckbooks posted:

You can encode this using binary decision variables and penalty terms. Main idea would be to subtract a big number if the items are not adjacent in the objective function.

<snip>

Constraints:

1. Ensure yijkl can only be 1 if both xij and xkl are 1. This can be modeled as:
yijkl ≤ xij
yijkl ≤ xkl

2. If yijkl is 1, then (i,j) and (k,l) must be adjacent. This means having constraints to enforce that only valid (k,l) values are used given a specific (i,j) value. Depending on the grid size, this can mean a large number of constraints.

Objective Function:
Objective = Other Criteria - ∑(i,j,k,l) in required pairs M × (xij × xkl - yijkl)
The bolded part is why I'm hesitant to use that solution; 16 cells * 16 options for each cell means I'd need to repeat the same set of constraints 256 times, plus any specific constraints depending on the cell and item, like the "8 is not in a corner cell" thing. That's a recipe for stupid errors in my experience, which is why I'm trying to make do with just one constraint function for the whole thing.

darthbob88
Oct 13, 2011

YOSPOS

Dijkstracula posted:

This is a great use-case for an SMT solver like Z3. Long story short is that SMT solvers are a bit like boolean SAT solvers on steroids: they use a SAT solver under the hood but let you encode richer datatypes than just bools.

I wrote the first few constraints here to get you started using the excellent Z3 solver:
<snip>
Most of the constraints I've left to you to implement, but hopefully you can see how from the ones I did implement. We can already see that z3 is finding solutions for the ones I did implement: For instance, every row, column, and diagonal has a mix of Roman and Arabic digits, and, the sum of the corners (8 + D=500 + 8 + D=500) equals the sum of row 3 (M=1000 + 0 + X=10 + 6).

code:
(venv) $ python3 griddle.py
8 M 0 D
0 0 0 M
M 0 X 6
D 0 0 8
(venv) $
That's exactly the sort of thing I spent a couple hours looking for last night and this morning. My only complaint is that I use .NET instead of Python, but they have a Nuget package.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

darthbob88 posted:

That's exactly the sort of thing I spent a couple hours looking for last night and this morning. My only complaint is that I use .NET instead of Python, but they have a Nuget package.

Yep, Z3 has bindings for a bunch of languages; Python's is especially good since they just overload every operator so things look as natural as possible, but I imagine C#'s is also perfectly fine too.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

darthbob88 posted:

The bolded part is why I'm hesitant to use that solution; 16 cells * 16 options for each cell means I'd need to repeat the same set of constraints 256 times, plus any specific constraints depending on the cell and item, like the "8 is not in a corner cell" thing. That's a recipe for stupid errors in my experience, which is why I'm trying to make do with just one constraint function for the whole thing.

It's not really that bad for 4x4, just a couple of for loops. i wouldn't use this technique on a chessboard though.

JamesieAB
Nov 5, 2005
I need some pointers on Flutter/Dart and viewing jpgs.

I've only found the assetimage and networkimage examples but need to get my images locally from a folder on a tablet or phone, like a subfolder of pictures on my android tablet.

What widget should I be using to show these images fullscreen and navigating through them with swipe gestures?

Could someone link me to a local image tuorial suitable for someone new to Flutter and Dart?

Thanks.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Will this help? https://www.woolha.com/tutorials/flutter-display-image-from-file-examples

I don’t use flutter but that seems to be the interface you want, and shows how to work with the perms you will need.

KICK BAMA KICK
Mar 2, 2009

(This might not be the most precise thread but it should be pretty simple and I am trying to drop this somewhere active cause I forgot until I saw the 24 hour notice this morning:)

I see there are some reasons you'd want to keep possession of say a business's old domain names even if you aren't using them. I've got a domain name that was just for personal use, never hosted any actual public-facing anything. I just used it to run through some tutorials and later serve a web control panel for some code that I was the only user of. Never did any business there; never used any email @ that domain. Not tied to my name or anything, and the domain name is nothing I, or anyone else, is likely to want in the future. Safe to let that go?

spiritual bypass
Feb 19, 2008

Grimey Drawer
The only possible downside is that a squatter may immediately snag it at expiration, denying you the opportunity to use it again

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
In particular if any of those old tools are still up and hard coded to point at its url, the new owner could potentially send some messages/responses/whatever with malicious data. That's more of an issue for bigger companies though -- it's pretty unlikely for anything like that to happen if you're a nobody, especially one with no public facing code.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

A Git question that has been weirdly difficult to Google an answer for:

I have a commit containing v1 of a project, say, with commits A -> B -> C. I started working on a v2 in a fresh repo, which now has commits Q -> R -> S. I'd like to merge v2 into the original v1 repo, but without overwriting the v1 commits (this seems to be the uncommon part), yielding a history something like A -> B -> C -> Q -> R -> S (it's fine if there's an intermediary commit in between C and Q; I just want to preserve the project's trajectory in a single place). How can I go about this?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


See Combine Git repositories with unrelated histories.

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

Dijkstracula posted:

A Git question that has been weirdly difficult to Google an answer for:

I have a commit containing v1 of a project, say, with commits A -> B -> C. I started working on a v2 in a fresh repo, which now has commits Q -> R -> S. I'd like to merge v2 into the original v1 repo, but without overwriting the v1 commits (this seems to be the uncommon part), yielding a history something like A -> B -> C -> Q -> R -> S (it's fine if there's an intermediary commit in between C and Q; I just want to preserve the project's trajectory in a single place). How can I go about this?

Add the refs from v2 to v1's repo. Give a name to S and Q. Checkout S. Rebase onto C by specifying you want to clip at Q.

huhu
Feb 24, 2006
I'm following the steps to create artifacts for my Electron app using https://github.com/marketplace/actions/electron-builder-action

The building for mac, windows, and linux runs smoothly and I get green checkboxes. I get to the release steps

code:
Releasing
When you want to create a new release, follow these steps:

Update the version in your project's package.json file (e.g. 1.2.3)
Commit that change (git commit -am v1.2.3)
Tag your commit (git tag v1.2.3). Make sure your tag name's format is v*.*.*. Your workflow will use this tag to detect when to create a release
Push your changes to GitHub (git push && git push --tags)
After building successfully, the action will publish your release artifacts. By default, a new release draft will be created on GitHub with download links for your app. If you want to change this behavior, have a look at the electron-builder docs.
I follow allow of them. I see the new release draft and I open it. However, it doesn't include download links for the app. What am I missing here?

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
What do the logs say?

huhu
Feb 24, 2006
So if I look at the workflow runs I see

code:
v1.0.5
Build/release #13: Commit abc123 pushed by huhu
13 hours ago  3m 18s v1.0.5
code:
v1.0.5
Build/release #12: Commit abc123 pushed by huhu
13 hours ago  10m 23s main
The workflow with main succeeds. If I look at the logs it looks like everything goes successfully.


The workflow with tag v1.0.5 fails:
code:
 &#10799; snapcraft is not installed, please: sudo snap install snapcraft --classic  
  &#10799; .../app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
So I'm currently a little confused as to why there are two workflows and why is one failing and one not.

foutre
Sep 4, 2011

:toot: RIP ZEEZ :toot:
I want to make a version of a Teamlab exhibit, where you project an image, and visitors can scan images in live and have them added to the scene (and then animate around, ideally). The goal is, for the viewers not to see any UI pop-ups or anything on the main, projected display, it would just update with the new image added. In the place I'm doing it I (probably) won't have a reliable web connection, so I'd need to do it locally.

I'm thinking I basically just want a space that can display an image, scan in new images and add them to a local folder, and then continuously check that folder for new images and display them as well. Initially I was thinking Unity, but I had a lot of trouble figuring out how to add images after the program is already running (it seems like 'StreamingAssets' would be the move, but that's read only).

I then tried Javascript, with a canvas, but ran into permissions issues - client-side, afaict, you can't get all the file names in a folder, you need a preloaded list. How would y'all approach this? Maybe there's a way to run a local server, so that you can check the file names with node or something server-side, and then feed them to the client? Would appreciate any advice for how to do this!

Would love any help, this seems pretty straightforward but the lack of internet connection is kind of throwing me. I feel like there's surely some easy solution I'm just missing!

e: Just figured out a version with PyGame - it's real ugly/not super performant, but it's something. If there's an easy way to do it in Unity or JS I'd still def be interested, I do find it easier to make the animated portions in those.

foutre fucked around with this message at 08:29 on Sep 28, 2023

huhu
Feb 24, 2006
Can you explain what you mean by lack of Internet connection? Could you host a web server locally that people could connect to?

Get some kind of device that'll let you set up a little network broadcasting a wifi signal that folks can connect to and host your website there.

Setup a frontend (React and JS for example)
- Have a view that displays the visuals
- Have a separate view that displays an image uploader

Setup a backend (Express and JS for example)
- Be able to host the images received from the frontend in a local folder

Setup a websocket connection between the two.
- When a new image is received, broadcast it out to all folks listening.
- Alternatively, you could poll the server every so often.

I believe that's roughly what you're afteR?

foutre
Sep 4, 2011

:toot: RIP ZEEZ :toot:
Oh, local network makes a ton of sense, for some reason I want thinking of that! That's a great solution, ty. For whatever reason I just was not getting there with the structure.

America Inc.
Nov 22, 2013

I plan to live forever, of course, but barring that I'd settle for a couple thousand years. Even 500 would be pretty nice.
I find it hard to believe that Python (1989) is older than Java (1995). I think most people associate Java with old enterprise software at this point, while Python is increasingly the first language people learn and it's the de facto language for new work in data science and machine learning. Even its Microsoft counterpart C# gets some traction as a language for game dev.

How and why did Java become such a rusty language only for brownfield development?

America Inc. fucked around with this message at 19:13 on Sep 29, 2023

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
No one actually used Python until the mid 2000s. In 2004 it was seen as a "comparatively esoteric language".

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply