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
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Dessert Rose posted:

yeah i hate to sound like a broken record (actually i don't just ask anyone who's ever heard me dj) but

emacs

also emacs, in fact emacs has a really fuckin rad extension (or ten) that resizes the window you're working on automagically so you get the most visual space where you actually need it


let me guess you think macs are dumb because they only have one mouse button too

what's it like posting from 1995

ok you've convinced me i'm going to do emacs

i like vim a lot i just want something with a concept of a project

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

MALE SHOEGAZE posted:

ok you've convinced me i'm going to do emacs

i like vim a lot i just want something with a concept of a project

emacs, the concept album of editors

if you are looking for a hobby, then curating emacs dot files will keep you busy for a long long while

a good gateway to emacs is org mode

Luigi Thirty
Apr 30, 2006

Emergency confection port.

my favorite text editor is emacson, lake, and Palmer

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Bhodi posted:

Because it's not 1995 anymore and we have things called graphical user interfaces with IDEs and editors that have things like tabs and side-by-side windows and MOUSE SUPPORT.

vim literally has every one of those features you dipshit. it has probably had them all for years. this really is the terrible programmer thread

Bloody
Mar 3, 2013

Tiny Bug Child posted:

vim literally has every one of those features you dipshit. it has probably had them all for years. this really is the terrible programmer thread

tbc was right/??????????

Bhodi
Dec 9, 2007

Oh, it's just a cat.
Pillbug
I'll go harder on the irony next time, sorry. I'll make it all caps next time. I've never legitimately used a mouse with vim though because I'm ssh'd into anywhere I'd use it...

There was once a guy who who joined the team and wanted to put emacs onto all our servers. The dependency chain resolved and spit back 150mb worth of packages. We laughed and laughed and told him to just use loving vi

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

MALE SHOEGAZE posted:

ok you've convinced me i'm going to do emacs

i like vim a lot i just want something with a concept of a project

install projectile

Bhodi posted:

I'll go harder on the irony next time, sorry. I'll make it all caps next time. I've never legitimately used a mouse with vim though because I'm ssh'd into anywhere I'd use it...

There was once a guy who who joined the team and wanted to put emacs onto all our servers. The dependency chain resolved and spit back 150mb worth of packages. We laughed and laughed and told him to just use loving vi

oh man, 150mb

that's like, almost one fifth of a gigabyte

Notorious b.s.d.
Jan 25, 2003

by Reene

Bhodi posted:

I'll go harder on the irony next time, sorry. I'll make it all caps next time. I've never legitimately used a mouse with vim though because I'm ssh'd into anywhere I'd use it...

There was once a guy who who joined the team and wanted to put emacs onto all our servers. The dependency chain resolved and spit back 150mb worth of packages. We laughed and laughed and told him to just use loving vi

emacs has remote editing

what kind of idiot logs into a server and runs an editor

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

tef posted:

if you are looking for a hobby, then curating emacs dot files will keep you busy for a long long while
one of my favorite new hobbies is "i have this new plugin that i need to configure, how can i write elegant lisp[1] to configure it without repeating myself" like so:
code:
(require 'diminish)

(eval-after-load "paredit"
  '(diminish 'paredit-mode))
(eval-after-load "undo-tree"
  '(diminish 'undo-tree-mode))
(eval-after-load "golden-ratio"
  '(diminish 'golden-ratio-mode))
(eval-after-load "helm"
  '(diminish 'helm-mode))
it's an interesting way to learn a new programming methodology by practical example

[1] lol oxymoron etc

quote:

a good gateway to emacs is org mode

i keep hearing about org mode and, just, what makes it so amazing? i mean i've wanted vim keybindings in onenote for a while but...

maybe i'll try using it to keep track of my accomplishments at work instead of writing them in separate onenote pages and see how it goes

Notorious b.s.d.
Jan 25, 2003

by Reene

MALE SHOEGAZE posted:

i like vim a lot i just want something with a concept of a project

i use projectile for this

it is hardly perfect but it's stupid simple

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
the "elegant" way of doing that thing i just posted:

code:
(require 'diminish)

(defun get-mode-sym (name)
  "Transforms a package name string into its corresponding mode symbol."
  (intern (concat name "-mode")))

(defun squelch-on-load (name)
  "Squelches a mode package's modeline entirely."
  (lexical-let ((mode-sym (get-mode-sym name)))
    (eval-after-load name
      '(diminish mode-sym))))

(mapc 'squelch-on-load (list "paredit" "undo-tree" "golden-ratio" "helm"))
the difference between let and lexical-let is, well

i'm sure there's some justification for it, somewhere

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
it seems it's time to read SICP just to customize emacs :getin:

I'm kinda surprised that emacs lisp has dynamic binding by default, wasn't rms a big fan of scheme?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Notorious b.s.d. posted:

what kind of idiot logs into a server and runs an editor

it's me, i'm the idiot who does that thing

and the editor i run is usually a gui emacs over a forwarded x11 connection

you'd think i'd remember to just use tramp but i wouldn't be in this thread if i made good decisions

cinci zoo sniper
Mar 15, 2013




same only i just sudo vi

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Ugh Jesus Christ the only time I use a remote GUI is to fix relatives macs

MononcQc
May 29, 2007

Notorious b.s.d. posted:

emacs has remote editing

what kind of idiot logs into a server and runs an editor

I do it on my VPS at the very least so that no matter what computer I'm on, I have a full Dev environment ready and waiting for me.

cinci zoo sniper
Mar 15, 2013




i have terrible coding question. say, there is an hls live feed, which is locked to a fairly bad player. there is a tool that allows me to extract this live feed and pipe it into whatever video player i want. i think of setting up a website with decent (non-flash) player to be able to avoid using monstrosity of a web player that is there now. in case if i do so and succeed to do so, i have one thing i am not sure about - will it cut into my bandwidth or will it work the way i think it would, as in direct client <-> endpoint connection that just uses my server as a means to "locate the signal" ?

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
who cares

cinci zoo sniper
Mar 15, 2013




:lol: i care i dont have infinte traffic on my vps

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

kalstrams posted:

:lol: i care i dont have infinte traffic on my vps

sorry not you i was talking about the vim/emacs/whatever debate

who cares

MrMoo
Sep 14, 2000

Is there a remote editing mode that doesn't download the entire file over some head-of-line blocking protocol? No one gives a poo poo, so mosh+vim forever.

cinci zoo sniper
Mar 15, 2013




Blinkz0rz posted:

sorry not you i was talking about the vim/emacs/whatever debate

who cares
oh i see
yeah i agree that there isn't much to care in that debate, just use whatever cuts it for you

Notorious b.s.d.
Jan 25, 2003

by Reene

Symbolic Butt posted:

it seems it's time to read SICP just to customize emacs :getin:

I'm kinda surprised that emacs lisp has dynamic binding by default, wasn't rms a big fan of scheme?

elisp is really, really dated. It resembles 1970s lisp. there is so much code depending on the badness, they are afraid to improve it. the only hope is that they add guile/scheme/cl as a side by side option with elisp.

they're actively working on a port of elisp to guile's interpreter in order to make elisp faster, and I am hoping this means guile-the-language is made available also

Soricidus
Oct 21, 2010
freedom-hating statist shill

Notorious b.s.d. posted:

they're actively working on a port of elisp to guile's interpreter in order to make elisp faster, and I am hoping this means guile-the-language is made available also
I guess it's about time something used guile

PokeJoe
Aug 24, 2004

hail cgatan


someone look at my terrible code and help me fix it. im taking cs50 at harvard online and none of the resources ive looked at have helped me. im given a card.raw from a camera and need to pull out deleted images. everything is stored in 512 byte blocks and the start of a jpg is guaranteed to be at the start of one of the blocks. im supposed to find 16 jpgs in the card starting at some point after the beginning. i am getting 16 images but only 5 of them are viewable. they have no errors. all the others are unviewable and corrupt. im supposed to look for the first four bytes of a jpg and start writing until i find another header to indicate that i need to make a new jpg. i checked all my output jpgs and they all start with the bytes i need.


code:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char* argv[])
{

    // check for validity
    if (argc != 1)
    {
        printf("Usage: Recovers JPEGs from a forensic image.\n");
        return 1;
    }
    
    //open card
    FILE* file = fopen("card.raw", "r");
    FILE* outptr = NULL;
    
    if (file == NULL)
    {
        printf("Could not open.\n");
        return 2;
    }
    
    // create buffer
    uint8_t buffer[512];
   
    
    char name[10];
    
    // counts images found
    int count = 0;
    
    // keep track of images
    bool new = false;
    bool found = false;
    bool foundfirst = false;
    
    
    
    // while not at the end of the file
    while (fread(&buffer, 512, 1, file) == 1)
    {
        
           if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && buffer[3] == 0xe0)
                {
                new = true;
                found = false;
                }
        
           if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] ==0xff && buffer[3] == 0xe1)
                {
                new = true;
                found = false;
                }
        // found a .jpg start
        if (new == true)
        {
            
             // close old jpg if new is found again
        if (foundfirst == true && new == true)
            fclose(outptr);
        
        //mark start of jpgs in raw file
        foundfirst = true;
       
        // writes file with proper naming scheme
        if (count < 10)
        sprintf(name, "00%d.jpg", count);
        else if (count < 100 && count > 9)
        sprintf(name, "0%d.jpg", count);
        else if (count > 99)
        sprintf(name, "%d.jpg", count);
        
        // open new file with proper name
        outptr = fopen(name, "w");
        
           if (outptr == NULL)
            {
              fclose(file);
              printf("Could not create .\n");
              return 3;
            }
        count++;
        found = true;    
        //write first block here
        fwrite (buffer, 512, 1, outptr);
        new = false;
    
        }
        
        // already started writing a .jpg
        if (foundfirst == true && found == true)
            fwrite (buffer, 512, 1, outptr);
    }
    fclose(file);
    fclose(outptr);
}

Brain Candy
May 18, 2006

PokeJoe posted:

someone look at my terrible code and help me fix it.

delete all the bools and use outptr to signal when you are writing

triple sulk
Sep 17, 2014



PokeJoe posted:

someone look at my terrible code and help me fix it. im taking cs50 at harvard online and none of the resources ive looked at have helped me. im given a card.raw from a camera and need to pull out deleted images. everything is stored in 512 byte blocks and the start of a jpg is guaranteed to be at the start of one of the blocks. im supposed to find 16 jpgs in the card starting at some point after the beginning. i am getting 16 images but only 5 of them are viewable. they have no errors. all the others are unviewable and corrupt. im supposed to look for the first four bytes of a jpg and start writing until i find another header to indicate that i need to make a new jpg. i checked all my output jpgs and they all start with the bytes i need.


code:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char* argv[])
{

    // check for validity
    if (argc != 1)
    {
        printf("Usage: Recovers JPEGs from a forensic image.\n");
        return 1;
    }
    
    //open card
    FILE* file = fopen("card.raw", "r");
    FILE* outptr = NULL;
    
    if (file == NULL)
    {
        printf("Could not open.\n");
        return 2;
    }
    
    // create buffer
    uint8_t buffer[512];
   
    
    char name[10];
    
    // counts images found
    int count = 0;
    
    // keep track of images
    bool new = false;
    bool found = false;
    bool foundfirst = false;
    
    
    
    // while not at the end of the file
    while (fread(&buffer, 512, 1, file) == 1)
    {
        
           if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && buffer[3] == 0xe0)
                {
                new = true;
                found = false;
                }
        
           if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] ==0xff && buffer[3] == 0xe1)
                {
                new = true;
                found = false;
                }
        // found a .jpg start
        if (new == true)
        {
            
             // close old jpg if new is found again
        if (foundfirst == true && new == true)
            fclose(outptr);
        
        //mark start of jpgs in raw file
        foundfirst = true;
       
        // writes file with proper naming scheme
        if (count < 10)
        sprintf(name, "00%d.jpg", count);
        else if (count < 100 && count > 9)
        sprintf(name, "0%d.jpg", count);
        else if (count > 99)
        sprintf(name, "%d.jpg", count);
        
        // open new file with proper name
        outptr = fopen(name, "w");
        
           if (outptr == NULL)
            {
              fclose(file);
              printf("Could not create .\n");
              return 3;
            }
        count++;
        found = true;    
        //write first block here
        fwrite (buffer, 512, 1, outptr);
        new = false;
    
        }
        
        // already started writing a .jpg
        if (foundfirst == true && found == true)
            fwrite (buffer, 512, 1, outptr);
    }
    fclose(file);
    fclose(outptr);
}


let's start with the first line. what does #include do?

PokeJoe
Aug 24, 2004

hail cgatan


Brain Candy posted:

delete all the bools and use outptr to signal when you are writing

why


triple sulk posted:

let's start with the first line. what does #include do?

it includes a header so i can use those libraries.

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

PokeJoe posted:

why


it includes a header so i can use those libraries.

looks like you copy everything up to the next image? shoudl you be lookign for the end of an image file also? This might be a good use case for a little state machine, have like a reading mode and a finding mode.

Im not seeing anything glaringly wrong (probably because I dont code C very often) but maybe you should also check the actual number of bytes read on every fread?

PokeJoe
Aug 24, 2004

hail cgatan


the assignment says not to worry about finding the end of an image separately from the beginning because they're stored contiguously on 512 byte blocks and the block is zeros from the end of the image to the end of the block and it shouldn't affect the output image if that part is included. i just stop writing an image when the start of a new one is found. i just can't figure out why only some of the images are viewable

fritz
Jul 26, 2003

Luigi Thirty posted:

my favorite text editor is emacson, lake, and Palmer

stallman brothers band

FamDav
Mar 29, 2008

triple sulk posted:

let's start with the first line. what does #include do?

this is a sincere question from terrible programmer and pughandler sulk

MeruFM
Jul 27, 2010
it's hard to tell sometimes

PokeJoe
Aug 24, 2004

hail cgatan


FamDav posted:

this is a sincere question from terrible programmer and pughandler sulk

lol

triple sulk
Sep 17, 2014



FamDav posted:

this is a sincere question from terrible programmer and pughandler sulk

we are all terrible programmers and that is why this thread exists

but if you really didnt get the joke it refers to atlas

Brain Candy
May 18, 2006


if you're reading from a stream that looks like this
[crap] [crap] .... [ jpeg_1] [ jpeg_1 ] ... [jpeg_1] [ jpeg_2] [ jpeg_2 ]
you're always writing after you start

why do you need two flags to check if you should write a block?

PokeJoe
Aug 24, 2004

hail cgatan


Brain Candy posted:

if you're reading from a stream that looks like this
[crap] [crap] .... [ jpeg_1] [ jpeg_1 ] ... [jpeg_1] [ jpeg_2] [ jpeg_2 ]
you're always writing after you start

why do you need two flags to check if you should write a block?

the start of the file is junk data so i use a flag to figure out when the first image starts, another to figure out if i need to start a new one, and another to see if i should write more blocks to an existing file. this way i don't write any files until the [crap] is over.

so its [crap] [crap] [crap] [jpg] < flag first found + new, write blocks till another [.jpg] is found, close old and write new blocks continuously until another if found. repeat until the file ends.

Brain Candy
May 18, 2006

PokeJoe posted:

the start of the file is junk data so i use a flag to figure out when the first image starts, another to figure out if i need to start a new one, and another to see if i should write more blocks to an existing file. this way i don't write any files until the [crap] is over.

so its [crap] [crap] [crap] [jpg] < flag first found + new, write blocks till another [.jpg] is found, close old and write new blocks continuously until another if found. repeat until the file ends.

you can interpret the problem as figuring out where to put the bytes, even if that's nowhere

have some pseudo-code that goes in the while loop

code:
if (matches_start) 
   if (outptr)
      close(outptr)
   outptr = open(nextFile())

if (outptr)    
   write_block(outptr)

PokeJoe
Aug 24, 2004

hail cgatan


Brain Candy posted:

you can interpret the problem as figuring out where to put the bytes, even if that's nowhere

have some pseudo-code that goes in the while loop

code:
if (matches_start) 
   if (outptr)
      close(outptr)
   outptr = open(nextFile())

if (outptr)    
   write_block(outptr)

But doesn't this just simplify my code? I can't see how it makes it functionally any different.

Adbot
ADBOT LOVES YOU

Valeyard
Mar 30, 2012


Grimey Drawer

PokeJoe posted:

the assignment says not to worry about finding the end of an image separately from the beginning because they're stored contiguously on 512 byte blocks and the block is zeros from the end of the image to the end of the block and it shouldn't affect the output image if that part is included. i just stop writing an image when the start of a new one is found. i just can't figure out why only some of the images are viewable

inspect the first and last byte of the working photos and then do the same for the first one that doesnt work

  • Locked thread