The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Internet & Technology (https://www.pokecommunity.com/forumdisplay.php?f=57)
-   -   The Coder's Lounge (https://www.pokecommunity.com/showthread.php?t=367308)

GoGoJJTech April 17th, 2016 7:03 PM

The Coder's Lounge
 
I'll just stick around to learn what everyone posts :)

EDIT: For my friend Team_Fail:

Danny0317 April 17th, 2016 7:06 PM

Add me to the list. I'm Danny and I'm pretty good at Java and C#. FBI is top bae.

So, some discussion now. Anyone here use the website kattis?
https://open.kattis.com/

It's pretty much just full on competition programming problems. It's great.

Tsutarja April 17th, 2016 7:12 PM

How about some PHP? Of course people say it's not the safest language for a web interface, but it was the first language aside from HTML and CSS I tapped into and got a grip on.

This is a snip of code from a PHP file I wrote that parses weather conditions from Wunderground (via XML), and since they don't parse wind speeds in kilometers per hour, I wrote this bit of code to do just that.

PHP Code:

//gusts in MPH to gusts in kmh
$initial2 $gusts;
$final2 1.6;
$gusts3 $initial2 $final2;
$gusts4 round($gusts3); 

Eh, hopefully I have time to ever so expand on my knowledge of PHP and also other languages out there.

Legendary Silke April 18th, 2016 10:10 AM

Quote:

Originally Posted by Dark Zeta (Post 9208279)
Unity (not sure of the differences between basic C#

Unity's default scripting language is C#. Pretty much everything you know about C# applies here, too, remembering that you should also be using some of the namespaces provided by Unity for obvious reasons.

JavaScript is also an option if you want to use that.

Nero April 19th, 2016 5:48 AM

Heya all! I haven't exactly been coding for very long, but I've got a fairly good understanding of HTML and PHP, and I recently began learning C#. I haven't really shown up in the Computers & Technology section before, but I'm gonna make an attempt to make this one of my go-to places on PC. I feel like I could pick up more than a few things here.

(By the way, it's Codecademy, not CodeAcademy :P)

Nero April 19th, 2016 11:44 PM

Quote:

Originally Posted by Ausaudriel (Post 9209550)
Awesome. What projects have you worked on?

Nothing very notable, just small things to help me improve a little. I'd have to say that the biggest thing I've ever coded is a fully operational forum, but I had a friend help me out with some CSS. I've never actually made something with a purpose other than to experiment, but not too long ago I was hired by a local earthmoving business to write a piece of software for them, so that's something. Programming is definitely something I want to get a lot more into, but I just have too many other time-consuming hobbies right now.

bobandbill April 21st, 2016 12:11 AM

Hi all!

I do some programming for my uni work. Primarily it's in Python with a bit of SQL (via sqlite), cgi and HTML, and on the odd occasion Matlab as well. I've also help tutor a couple uni courses in Matlab and C.

I've touched other languages briefly (mostly for uni coursework some years back... e.g. Fortran90) and did a few things back in high school/bit after in Flash with Actionscript 2.0 (which isn't too different from C I suppose).
Quote:

Originally Posted by Team Fail (Post 9211133)
I've kinda done the same thing with C#, actually. I've been writing small programs in an effort to learn how it all works, and it's really been helpful. Forcing yourself to get something working tends to be the best way to find out how to get something working, next to looking it up on Stack Overflow that is.

Ah, good old Stack Overflow. Usually has helped me out.

ジュナイパー April 21st, 2016 12:52 AM

Cool, this exists!

While I haven't coded in a while, I have a beginner-that-knows-what-they're-doing's knowledge of JavaScript, HTML5, and CSS/CSS3.

Impo April 21st, 2016 6:12 AM

For my uni course I've learnt coding for Java fairly well!

I learnt Python in my first year and C++ and Visual Basic in my second, but they didn't stick quite as well as Java!

I want to learn swift and/or Objective-C so I can work with apple development - cause that sounds like fun!

Danny0317 April 21st, 2016 6:29 PM

Anyone here learn Java as a first language? I did, and now every other language I see (not counting C#) just looks so.. ugly.

Just me?

Impo April 21st, 2016 9:17 PM

Quote:

Originally Posted by Team Fail (Post 9212103)
C# was really my first, but Java is really similar to it. However, I find that the syntax in some languages is really nasty at first. I thought that for C and C++, but it's making sense to me now that I've began to use it more and more with my Arduino.

I know when I still hate C++ because of its syntax!
My lecturer will use all these shortcuts right at the beginning and I don't think he told anyone what they meant haha

Swift also sucks because I haven't seen anything like it before, so I'm tossing up between that and Objective-C

Lucario April 22nd, 2016 3:02 AM

I'm decent at python, and can find my way around html/css/js quite well. I mostly do gdscript (godot engine) now, and a bit of SQL. I know so little C it's not worth talking about. Oh yeah, and BBC BASIC.

esperance April 22nd, 2016 5:44 AM

Hey, you can add me to the list.

My best language is C#, but I also enjoy programming in Python and Lua. More recently I've been working with D and Swift, and a tiny bit of F#. Because of schooling I've become pretty good at Java and Matlab... As for web stuff, I guess knowing HTML and CSS counts, and I've used JavaScript very briefly. I haven't worked with PHP in a couple years, so I can't really say I know it anymore.

Some languages that I've tried but haven't stuck with are Haskell and Julia.

BluRose April 22nd, 2016 2:46 PM

ヽ༼ຈل͜ຈ༽ノ C+= OR RIOT ヽ༼ຈل͜ຈ༽ノ
I can do some Java but that's about it. Next year will be my big expansion into coding languages, likely... Just as an introduction thing, haha...

Impo April 23rd, 2016 4:21 AM

I actually have a question for a few coders!!

It's regarding app development in xcode - objective-C or swift?

I'm going to be starting this project soon to get a better knowledge of app development, and wanna see what people think!

esperance April 24th, 2016 11:21 AM

Quote:

Originally Posted by Impo (Post 9213250)
I actually have a question for a few coders!!

It's regarding app development in xcode - objective-C or swift?

I'm going to be starting this project soon to get a better knowledge of app development, and wanna see what people think!

Since your introduction post said you're familiar with Java, Swift might be nice to look into. It's a modern language that should have a familiar enough syntax. It is quite new, so there isn't as much support and examples our there compared to Objective-C, and the language has been constantly changing. But, you'll find that Swift is much more beginner friendly.

Impo April 24th, 2016 6:43 PM

Quote:

Originally Posted by Youmu (Post 9214774)
Since your introduction post said you're familiar with Java, Swift might be nice to look into. It's a modern language that should have a familiar enough syntax. It is quite new, so there isn't as much support and examples our there compared to Objective-C, and the language has been constantly changing. But, you'll find that Swift is much more beginner friendly.

Thank you for the suggestion, I'll probably use swift! I did learn a bit of it in my uni course, so it will be good to add onto that base knowledge. Cheers!

Lucario April 25th, 2016 12:06 AM

Oh yeah, can you add me to the list?

Tsutarja April 25th, 2016 6:44 AM

So in the fall I'll be taking a class on Visual Basic as part of my degree. Would y'all say there's anything I'd need to possibly learn/look at to make sure I don't walk into the class without knowing anything?

Syntthetix April 25th, 2016 5:33 PM

Hey, add me in! I'm a bit of a beginner with programming, but I'm working my way up little by little. I work with Java, I've done a little C#, I mess around with Batch every once in a while just for fun, and I've entirely forgotten HTML :) It'll be cool to see a whole thread on programming here!

Rukario April 25th, 2016 6:17 PM

hmm.. guess I've never written a single line of code in my webmastering history or as a webdesigner, etc.. yup not a single line.

Megan April 26th, 2016 1:25 PM

I have a basic understanding of programming, due to a couple semesters of learning Computer Science. However, I only occasionally work on the programming projects that I have. Focus mostly lies on C# and sometimes a little bit Python3. Also had a little bit of C++ and Haskell in the past, though I wouldn't really count them as I haven't done anything with them for ages.
Quote:

Originally Posted by Rukario (Post 9216050)
hmm.. guess I've never written a single line of code in my webmastering history or as a webdesigner, etc.. yup not a single line.

Well, it's called web"master" for a reason. The hard work is privilege of the lowly servants. {XD}

Hiidoran April 26th, 2016 5:24 PM

Quote:

Originally Posted by Team Fail (Post 9215606)
Visual Basic, in my honest opinion, isn't the greatest language to start with, because it isn't very standardized in terms of syntax versus other languages.

This.

Visual Basic was the first language I ever had experience with, as it was the language taught in my high school programming class. I picked up on it really quickly and actually enjoyed it a great deal, but learning that syntax first made for a hard transition to other languages. Though maybe "hard" isn't the best word? Perhaps the syntax habits were just hard to break.

Oh, and hi! I wouldn't consider myself adept or even very knowledgeable about programming at all, but I have been picking it back up lately and playing around with it. As I've said my experience with coding stems from Visual Basic, but I've also taken a course in HTML and CSS while in college, dabbled with JavaScript, Actionscript waaaaay back, and now I'm mostly trying to focus on C# to have a more modern, versatile language to play with. :>

Zet April 26th, 2016 6:26 PM

Quote:

Originally Posted by Tsutarja (Post 9215527)
So in the fall I'll be taking a class on Visual Basic as part of my degree. Would y'all say there's anything I'd need to possibly learn/look at to make sure I don't walk into the class without knowing anything?

Learn to make a GUI interface to track the killer's IP address.*




*You're pretty cool if you got that reference.

While not programming languages, I know HTML and CSS. As for programming languages I only know a tiny bit of JavaScript.

catrap0 April 27th, 2016 12:22 AM

Learning Python and took a semester of C, so hoping to learn to make some gaming scripts later =3

GiovanniViridian April 27th, 2016 7:29 AM

Add me please even though I'm sort of an amateur lol.

Languages: C++, Java, Shell, Javascript, HTML, CSS (and some others I forgot)

Ky0greK1ng April 28th, 2016 5:57 PM

Hey!

I'm not sure if this counts, but I know a lot about GameMaker Language (GML). I've coded a lot of platformer games and simple fighters.

If that's acceptable, I'd love to be added to the list!

Impo April 28th, 2016 10:06 PM

Well I tanked my coding test today (:

I am not very comfortable with the libgdx framework and I think it may have shown.. hehe.. oops

has anyone else used libgdx before?

Buu April 28th, 2016 11:58 PM

Thought I'd just jump on this train to brag.

PHP, HTML, CSS. Expert in vBulletin Invision Power Board and services.

Former Head Admin of Crazy-Coderz (rip) and current owner of an invision project.

Feel free to shoot me any questions :)

Impo April 29th, 2016 3:10 AM

Quote:

Originally Posted by Team Fail (Post 9219833)
I've never heard of it, but I'm still learning so yeah. I'm borderline failing my Robotics class, but I can hand in a few things and try getting my Robot finished, as we got a half-day extension since our prof got first-hand experience on how much our robot is not working and that we've had to struggle with it.

It's a framework for games, it's pretty cool actually! I don't mind failing cause I'll get it in the end, but it was 20% of my grade! I picked a whole bunch of oopsie-daisies.

But robotics sounds way cooler!! What robot are you trying to make?

Impo April 29th, 2016 6:31 PM

Quote:

Originally Posted by Team Fail (Post 9220297)
Ah, a gaming framework? That'd be a lot.of fun to play with. I'm thinking on playing around with an unofficial devkit called Devkitpro. It lets me make games for different consoles, including most recent Nintendo consoles.

It's actually a robot that we build ourselves and program an Arduino to work with. It's fairly tedious work though. There's a lot you need to keep in mind, especially when it comes to power usage, and calibration of your sensors to prevent unnecessary noise and inaccurate results.

Devkitpro sounds so cool!

That robotics stuff does sound hard, but I bet it pays off in the end! I wish you the best of luck :)

Sopheria April 30th, 2016 11:46 PM

Just thought I'd join this, I'm always happy to chat about coding and meet fellow coders :3

I'm a full-time software engineer and web developer. I work on identity management software which handles user authentication, authorization, and single-sign on across different web services. I know and have worked with all of the major languages to varying degrees, but the ones I work with most frequently are PHP, Perl, and Javascript.

Hello all n_n

txteclipse April 30th, 2016 11:49 PM

Hey peeps! I'm a software engineer by trade and my strongest languages are C and Java. I'm doing a lot of Android work right now and also trying to find a game engine that doesn't drive me crazy for some hobby projects. I'm a big fan of parallel processing, and have a decent amount of experience with CUDA and OpenGL.

I've got some experience with libgdx, Impo, but not a lot. It worked pretty well for a small game app I did in school.

Flowerchild May 1st, 2016 1:22 AM

I don't really think it's worth putting me on the list since I'm not really proficient in... anything, but I do some amateur coding from time to time. I've done stuff mostly with JavaScript and Java, and these days I'm very slowly learning Ruby (mostly by digging through the code for Pokémon Essentials) and C++ (which frustrates me forever). Looking forward to chatting with y'all!

Impo May 1st, 2016 1:27 AM

Quote:

Originally Posted by txteclipse (Post 9222523)
I've got some experience with libgdx, Impo, but not a lot. It worked pretty well for a small game app I did in school.

Oooo that sounds exciting! What game did you make?

I have to make a game for a group assignment and I'm scared (:

Tsutarja May 6th, 2016 5:59 PM

I've been wanting to code something in PHP for sometime (whether by modifying my current project) or just making something new and original.

Hmm, ideas ideas. :P

Wunkolo May 6th, 2016 6:35 PM

Very big on C++ and native-code in general. Not a huge fan of managed environments like C#/Java/etc for "serious" coding. When it comes to performance and general programming C/C++ is my home base. Experience in x86/64, ARM, PPC, Z80, and 6502 from lots of reverse engineering.

KetsuekiR May 8th, 2016 1:52 AM

I'd like to be added to the list.

I've dabbled in multiple languages but the ones I've used the most are, in this order, HTML/CSS (if it counts), C#, Python and Java, although I've mostly forgotten Java and most of Python. xD I look forward to being here and learning from you all! c:

Impo May 9th, 2016 1:47 AM

I have a question for the coders of PC! It's one regarding storing data (let's see if I can word it right :x )

I'm experimenting in swift trying to make an app, and it's very fun! It's essentially a pedometer and by taking steps you hatch and level Pokemon. So fun! But I have come across a problem: I have a ton of Pokemon and variables to store for them (steps taken, level, happiness, etc) which will change throughout the app, but a lot of the other variables (sprites, overworlds, icon, name, type, max exp, exp growth type, etc) will only ever be the same thing. Is there a way to store all of the latter data before instantiating it with the former variables?

(I hope that made sense...)

KetsuekiR May 9th, 2016 4:10 AM

From what I understand, you want some values to stay the same throughout your app while some can be changed at a time after instantiating them, yeah?

You could set the values you want to remain the same as constants and the rest as ordinary variables. I looked it up and it seems like the code for setting constants in Swift
is by using "let" as follows;

Code:

let maximumNumberOfLoginAttempts = 10


I hope that's what you were looking for! c:

Impo May 9th, 2016 6:20 AM

hmm.. not quite, but I appreciate the help :) !

I will have to use let in the class no doubt, so you are right :) !
But I was hoping there would be a way to import the data from like a text file or something, because I don't want/know-how to write it in the Pokemon class (could you imagine like 300+ if statements to figure it out dear lord help me haha)

esperance May 9th, 2016 7:49 AM

Quote:

Originally Posted by Impo (Post 9232970)
I have a question for the coders of PC! It's one regarding storing data (let's see if I can word it right :x )

I'm experimenting in swift trying to make an app, and it's very fun! It's essentially a pedometer and by taking steps you hatch and level Pokemon. So fun! But I have come across a problem: I have a ton of Pokemon and variables to store for them (steps taken, level, happiness, etc) which will change throughout the app, but a lot of the other variables (sprites, overworlds, icon, name, type, max exp, exp growth type, etc) will only ever be the same thing. Is there a way to store all of the latter data before instantiating it with the former variables?

(I hope that made sense...)

What you'll wanna look up is data persistence in Swift. Here's something to get you started:
http://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-data-persistence-and-sandboxing-on-ios--cms-25505

Impo May 9th, 2016 7:47 PM

Quote:

Originally Posted by Youmu (Post 9233376)
What you'll wanna look up is data persistence in Swift. Here's something to get you started:
http://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-data-persistence-and-sandboxing-on-ios--cms-25505

Thank you very much! I will keep looking up more tutorials and see how far I get :) !

Radix May 25th, 2016 8:53 PM

Add me to the list.

I work on a variety of personal and open source projects. I mostly use Haskell and ES7/Javascript, but I know a bunch more. Recently I've been really into UI architectures, and I've worked on a bunch of shiny new stuff in the React/CycleJS/Elm community as a professional web developer.

SushiFeelings June 6th, 2016 1:35 AM

Hey everyone, I recently joined these forums and thought this thread looks pretty neat. I'm currently a student majoring in CS, but I noticed there is a lot of stuff they don't really teach so I've been wanting to learn a few things on my own this summer. I've dabbled into Java, Python, C, Scheme, PHP, and a few more. However I don't really feel that proficient in any of the languages.

Currently I've been dabbling in Meteorjs for webdeving and trying to get a few sites going with it, but I was wondering what other projects or languages I could learn that could be beneficial in the future?

esperance June 7th, 2016 11:12 AM

Quote:

Originally Posted by Team Fail (Post 9274152)
So over the past few days, I've been working on one of the summer projects that I have been wanting to do with a co-worker of mine. Basically, the program is to be used in our workplace (And yes, I do have permission from the store manager about this!) and allows us to get product information on the floor by simply typing in an item number, and it'll return a price, name, and image of the product so far, although I do have plans for some other features in the coming days. I've been learning a lot about how this goes, especially the workflow of developing an application and bugtesting it, but I've also used WPF for it instead of standard Winforms, as I wanted to use a different UI library so it didn't look so absurdly plain. It's been working out though, although what I already know in C# so well is being put into question as WPF implements C# ever so slightly differently.

What is WPF like for C#? I've never worked with it before so I'm curious.

Margot June 9th, 2016 7:53 PM

Hey, guys!

I'm not a programmer by any means, but I am really comfortable with HTML/CSS and took a couple classes in Javascript and C++ in college. During my downtime at work, I like to plan out programs and have been working on a couple in C which I have been slowly teaching myself. Once I have a better hold on it, I'd like to get back to Javascript.

I just wanted to pop in and say hi, especially since I may come in here from time to time with questions~

Lucario June 13th, 2016 7:03 AM

I'm trying to build the qt version of vgmtrans under linux as I post this, might have to do some code tweaks to get it to run.

Tsutarja August 10th, 2016 6:38 AM

Quote:

Originally Posted by Team Fail (Post 9360787)
hi Zach

What kind of project were you working on at your job, if I may ask? :o

Tsutarja August 10th, 2016 9:10 AM

Quote:

Originally Posted by Team Fail (Post 9361655)
Well, basically every item in the store has a product number associated with it. My program you could type in that number, and it'd try to get product information from the store's website and use a web scraping utility to do it and give that information back to the store employee. Some people that saw and tried the older betas really liked it, but because of this policy, I'd have to have express approval from Head Office for any kinds of floor testing.

Wow, that kinda sucks but at the same time I'd like to see if you could go forward with it!

Tsutarja September 4th, 2016 8:31 PM

So I'm taking Visual Basic this semester and I have a question...has anybody ever had to program Hello World? My professor is making me do that as the first assignment.

esperance September 6th, 2016 9:27 AM

Quote:

Originally Posted by Tsutarja (Post 9395322)
So I'm taking Visual Basic this semester and I have a question...has anybody ever had to program Hello World? My professor is making me do that as the first assignment.

Definitely! Hello World is always the first exercise given when learning a new programming language. ;)

Tsutarja September 6th, 2016 11:18 AM

Quote:

Originally Posted by Lost (Post 9397566)
Definitely! Hello World is always the first exercise given when learning a new programming language. ;)

haha :P

It was definitely fun to work with the code, although I definitely had some trouble in the beginning. In fact, I accidentally started the project as a C# project instead of Visual Basic in Visual Studio and had to start over. -_-

Designing stuff in the GUI made things seem like there was nothing wrong, until I got to the coding of the buttons.

Tsutarja September 6th, 2016 1:25 PM

Quote:

Originally Posted by Team Fail (Post 9397726)
Yeah, VB does its syntax super weird and it just doesn't really make much sense in comparison to pretty much all other languages. It's good to have, but it doesn't develop good habits.

In that case, then I do wonder why my college is making me take Visual Basic, unless a lot of IT professionals use VB. They have a programming track that teaches all other languages, but I feel that for my computer information administration program, VB was just a pull from the hat.

esperance September 6th, 2016 5:34 PM

Quote:

Originally Posted by Tsutarja (Post 9397775)
In that case, then I do wonder why my college is making me take Visual Basic, unless a lot of IT professionals use VB. They have a programming track that teaches all other languages, but I feel that for my computer information administration program, VB was just a pull from the hat.

You'd be surprised how much VB is used in the business world... certainly not on the level of a language like C++ but it's up there from what I know. As for using VB in a beginner language class, well, the language is rather accessible for non-programmers to grasp which makes it a good language to at least get your feet wet with.

Alex September 6th, 2016 6:08 PM

Heey im starting a web dev fundamentals course next week. Should be fun, but might be exhausting while working 40+ hours/week.

Hiidoran September 8th, 2016 9:02 PM

VB was my first language; it's very accessible to programming neophytes. I think they've made the GUI a little more complicated in recent years, but honestly, you could get a decent grasp of it in an afternoon - and linking code to it is SUPER easy in Visual Studio.

Long story short, I think people still use VB because you can get a decent program up and running quickly.

The syntax though... well, it's been hard unlearning it in order to grasp more powerful languages, I'm finding. :x

wakachamo September 13th, 2016 9:57 PM

Quote:

Originally Posted by Team Fail (Post 9403471)
That's really the one thing I dislike about it. If it had a more in-line syntax with regular languages, it'd actually be something I'd recommend more to beginners to grasp the concepts of programming.

I think that's always an obstacle... it's the same sort of thing when you're transitioning from say, a garbage-collected language and a manual memory language—whatever habits you have that didn't necessarily have to deal with pointers and memory addresses will need to be changed. Learning new languages is a matter of constantly breaking old habits. :)

Leviathan September 26th, 2016 6:29 AM

I feel that when it comes to NetBeans. Like it's useful for coding in Java, but I might be forced by college to use it for PHP dev'ing soon? So ughhhh. Lemme code in peace with something far more lightweight like Notepad++ which has an actually decent dark theme on it. <3

Also been having to make own version of some in-built php functions recently. It's actually kinda fun doing the legwork myself, but at the moment I'm trying to make a custom remove from array function and I'm getting annoyed 'cuz I know how to do it in C++ or Java already. Haha.

Megan September 26th, 2016 10:06 AM

Our company is using Delphi (7, but they plan on slowly upgrading to the newest version). I have to say, it feels pretty weird using it, especially since I'm so used to stuff like C/C++ and C# and their syntax.

Megan September 30th, 2016 10:19 AM

Quote:

Originally Posted by Team Fail (Post 9427923)
I'm still trying to wrap my head around understanding x86 assembly right now. There's so much going on in even the most simple of programs, and even with the libraries that we have you have to be mindful of everything because it's not hard to overflow a register with a value by accident or accidentally processing garbage data.

So you're working with x86 assembly right now? Dunno much about stuff like that. Anything assembler and registers is way over my head (still remember all the trouble I had in university when we had to deal with that stuff).

What I kinda don't like about Delphi is their weird indexing convention. Like, there's literally some types that you need to start by element 1 whereas others start with the 0 index which is pretty much the standard on every other language I used before. And I always find myself in the situation of asking myself if I even used the right one. {XD}

Caite-chan October 2nd, 2016 5:44 AM

I wish I knew and understood more. I just have very basic HTML and CSS. I always say I know enough to have my own site before WordPress...lol. I couldn't write my own stuff but I could take a template and modify it to what I needed.

gimmepie October 2nd, 2016 6:56 AM

So, I've started working on a project and in theory the only work with code I should need to do is copying code for macros that other people have posted up and then changing values to make it do what I want. That's basically the extent of my coding ability outside the worlds most limited CSS/HTML knowledge.

Which leaves me with a problem when this happens
http://i.imgur.com/j64Ek7c.png

Can someone translate that to English and tell me what it means so I can work out what I need to change to make it work?

If it helps this is using javascript.

Tsutarja October 5th, 2016 8:07 AM

If there's one thing I find annoying with Visual Basic, it's Dim statements. :P

Tsutarja October 5th, 2016 11:31 AM

Quote:

Originally Posted by Team Fail (Post 9437249)
And not the lack of semicolons???

Oh gosh you're right XD

Rune October 7th, 2016 9:07 AM

Hi all! I was referred to this thread by Team Fail himself on Discord :D

Now, I'm mostly an artist though but living in San Francisco for years made me seep into this coding thing. Although I 'began' coding like way back in middle school with BASIC and Visual Basic as well as a little (very little that it's very insignificant) Python v.1, Flash, and HTML at a vocational school, these didn't really teach me anything.

It wasn't until as recent as 2014 that circumstances forced me to learn PHP, HTML, and CSS partly kicking and screaming. 2015 was a vacuum year in coding as well since I really focused on art a lot more. It wasn't until the beginning of 2016 where I finally met a coding buddy and my proficiency shot to the moon.

tl;dr, I'm pretty much a noob and coding isn't really my 'main' thing but I am actively learning. I am proficient in PHP (although I'm avoiding it like a plague now), HTML/CSS, Javascript (JQuery, Vue.js, React, and node). I'm currently waist-deep in Go that it's pretty much my primary language. Also have worked in VB, Python, Ruby, Flash but nothing significant.

Tsutarja October 7th, 2016 5:35 PM

Quote:

Originally Posted by Rune (Post 9439579)
Hi all! I was referred to this thread by Team Fail himself on Discord :D

Now, I'm mostly an artist though but living in San Francisco for years made me seep into this coding thing. Although I 'began' coding like way back in middle school with BASIC and Visual Basic as well as a little (very little that it's very insignificant) Python v.1, Flash, and HTML at a vocational school, these didn't really teach me anything.

It wasn't until as recent as 2014 that circumstances forced me to learn PHP, HTML, and CSS partly kicking and screaming. 2015 was a vacuum year in coding as well since I really focused on art a lot more. It wasn't until the beginning of 2016 where I finally met a coding buddy and my proficiency shot to the moon.

tl;dr, I'm pretty much a noob and coding isn't really my 'main' thing but I am actively learning. I am proficient in PHP (although I'm avoiding it like a plague now), HTML/CSS, Javascript (JQuery, Vue.js, React, and node). I'm currently waist-deep in Go that it's pretty much my primary language. Also have worked in VB, Python, Ruby, Flash but nothing significant.

Hey there, glad to see he directed you this way :)

I'm somewhat proficient in PHP; I coded a whole web application in PHP almost from scratch as my first dive into programming. Although I don't touch PHP anymore, I'd love to become more proficient.

Rune October 12th, 2016 1:34 PM

Quote:

Originally Posted by Tsutarja (Post 9440076)
Hey there, glad to see he directed you this way :)

I'm somewhat proficient in PHP; I coded a whole web application in PHP almost from scratch as my first dive into programming. Although I don't touch PHP anymore, I'd love to become more proficient.

I maintain a web application in PHP that someone wrote. I've never written anything from scratch but when I learned Laravel earlier this year, I pretty much got PHP when I managed to clone the application to an extent. In my honest opinion, PHP shouldn't really be used for a complex project anymore because as they say, it's a double-clawed hammer.

Cordeline November 5th, 2016 8:05 PM

Hi all, I think this is the right place for me to ask this question. ^^

I am interested in learning some more programming. Everyone in my family is an engineer (even my mom programmed in college she told me hahaha), and while I have no interest in engineering or computer science in general, programming looks very interesting. Currently I know a little bit of Bash and Python that my brothers and my dad taught me, and while I can't do big things, I can do small things that help me a little bit to keep my files organized. For example, I take a lot of screenshots of the anime I watch on VLC and the file names contain the name of the anime, so I have a script that will put the screenshots in folders with the anime name that runs every 5 minutes, and things like that.

But I'd like to go beyond that and write better things for myself. For example, my brothers helped me write a script that checks when a new episode of an anime I'm watching is available and sends a notification to my phone (with an app called Pushover). They did the heavy work of actually checking for episodes and I just wrote the notification script. I want to write things like that to, um, automate my life a little ^-^.

So my question is, is there any book or anything I can read and practice to write that kind of tools? My interest in programming is mostly to automate things for myself. I am not too interested in writing web sites or desktop applications or fancy things like that, at least right now when I want to spend most of my time practicing music.

I have googled a little bit and people always recommend me to learn Java. I have looked into it and tried to follow a few tutorials but it looks like people use it for big stuff like app development and at least right now that kind of thing goes over my head. My brothers recommended me to either learn Swift or improve on Python. I know Swift is also used for big stuff but my brothers showed me that a lot of the stuff I do with Bash can be done with Swift, but with a few more lines of code.

I guess the first thing I want to do is to write my very own anime episodes checker without my brothers help. What would you do? Would you pick an new language like Swift or should I just stick with Python for this? My brother, who is very skilled with programming and has participated in many programming contests and has published some apps on both stores, told me that even he wouldn't try to do write that entire program on Bash so I guess that one is out of the question for this specific script hahaha.

Megan November 6th, 2016 12:48 AM

Quote:

Originally Posted by Cordeline (Post 9477099)
Hi all, I think this is the right place for me to ask this question. ^^

Python is pretty beginner-friendly while still providing a lot of functionality that allows even high level programming. Sticking to it is definitely a good choice. Bash on the other hand isn't a programming language per se, because it just strings programms together to accomplish whatever needs to be done.

If you don't want to go deeply into programming, then languages like Java might not be worth your while, because they usually require a lot more research and practice, especially when you're new to their concepts (object oriented programming, etc.).

wakachamo December 8th, 2016 9:42 PM

Quote:

Originally Posted by Cordeline (Post 9477099)
Hi all, I think this is the right place for me to ask this question. ^^

I am interested in learning some more programming. Everyone in my family is an engineer (even my mom programmed in college she told me hahaha), and while I have no interest in engineering or computer science in general, programming looks very interesting. Currently I know a little bit of Bash and Python that my brothers and my dad taught me, and while I can't do big things, I can do small things that help me a little bit to keep my files organized. For example, I take a lot of screenshots of the anime I watch on VLC and the file names contain the name of the anime, so I have a script that will put the screenshots in folders with the anime name that runs every 5 minutes, and things like that.

But I'd like to go beyond that and write better things for myself. For example, my brothers helped me write a script that checks when a new episode of an anime I'm watching is available and sends a notification to my phone (with an app called Pushover). They did the heavy work of actually checking for episodes and I just wrote the notification script. I want to write things like that to, um, automate my life a little ^-^.

So my question is, is there any book or anything I can read and practice to write that kind of tools? My interest in programming is mostly to automate things for myself. I am not too interested in writing web sites or desktop applications or fancy things like that, at least right now when I want to spend most of my time practicing music.

I have googled a little bit and people always recommend me to learn Java. I have looked into it and tried to follow a few tutorials but it looks like people use it for big stuff like app development and at least right now that kind of thing goes over my head. My brothers recommended me to either learn Swift or improve on Python. I know Swift is also used for big stuff but my brothers showed me that a lot of the stuff I do with Bash can be done with Swift, but with a few more lines of code.

I guess the first thing I want to do is to write my very own anime episodes checker without my brothers help. What would you do? Would you pick an new language like Swift or should I just stick with Python for this? My brother, who is very skilled with programming and has participated in many programming contests and has published some apps on both stores, told me that even he wouldn't try to do write that entire program on Bash so I guess that one is out of the question for this specific script hahaha.

If you have an iPad, Swift Playgrounds is a great start to learn the foundations of code. Whether it's Swift or Python or (contrary to some statements here) even Java, it doesn't really matter which one of those you learn first. If you're thinking of making a career out of this, you're likely to have to learn another language at least once anyways—all that matters is how well you can transition from one language to another.

Lucario December 9th, 2016 12:11 AM

Is there a "C++ for C programmers" guide anywhere? I'm a C programmer, but I'd like to write a program that uses a specific library that's C++ only. Any help?

Tsutarja December 9th, 2016 9:18 PM

Quote:

Originally Posted by Lucario (Post 9512773)
Is there a "C++ for C programmers" guide anywhere? I'm a C programmer, but I'd like to write a program that uses a specific library that's C++ only. Any help?

This probably isn't any help directly, but I'm sure a Google search could turn up what you're looking for, especially if you specify which library you're using or need to use in your query.

After a Google search for what you have in quotes up there, I found this. Not sure if it's what you're looking for, but it's something:
http://www.embedded.com/design/programming-languages-and-tools/4424383/A-guide-to-C--for-C-programmers

kitarei January 22nd, 2017 6:48 PM

Hi all - Tsutarja kindly pointed me over here so I thought I'd pop in and introduce myself.

I'm currently still completing my degree and working for the Australian Public Service. I mostly work with Java, Javascript, SQL, HTML, CSS, and PHP. I've also dabbled ever so slightly in mobile development with Java for Android and Swift for iOS.

I have a corporate account with pluralsight.com who recently aquired codeschool.com, so I've been enjoying going through some of the courses on the latter in between university and work commitments.

kitarei January 22nd, 2017 8:13 PM

Quote:

Originally Posted by Johnny (Post 9554663)
I follow a youtuber who works for pluralsight, his channel's called 'Simple Programmer'. Can't remember his name, but he's a super cool guy and has a lot of interesting videos.

I just went to check him out, his voice sounds really familiar! According to his About section he's an author on Pluralsight, so maybe I've listened to one of his courses before.

His youtube vids look pretty cool though, I'll have to watch some :)

Flowerchild January 22nd, 2017 9:49 PM

Hi! I may pop by here more since I've been programming a ton lately. My favorite languages are Ruby and Python - I used Ruby for my fangame and tend to use Python for random projects - though mostly lately I've been doing coding the PC Discord bot, which runs in JavaScript. I'd also like to check out PHP sometime in the future!

Megan February 18th, 2017 3:02 AM

Is anyone of you adhering to certain standards when working on your projects? I'm also curious if there's people who like to use some of the more arcane features that a lot of programming languages feature.

M.E.R.255 April 19th, 2017 8:19 AM

Hey, can I annoy any of you guys with my excessive dialouge by joining into the conversation? =P
Don't worry. I'll leave suggestions in suggestion section, so there won't be any of it here. ;D

Well, since we're just talking, has this ever happened to you?
"Dum bi dum bi dum! Ooh! I just had a genius idea! OoO People keep seeking out for the admin folder and try getting into it, but what if they couldn't find it because it would use special character's they'd never expect? OuO Yeah! Genius! I'll just name admin to... “@™¡ñ”
*a day later*
"Alright! Let's try adding some files to my... @ folder? Hey wait a minute! What happened to the name? O_O Oh well, maybe FileZilla is glitched. =P"
*tries to access it*
"Huh? Won't work? Okay...? Well, maybe I'll just rename or delete it. ^^"
*won't let me*
"Oh oh... Uh... um... s-surely the hosting site's file management can delete that! =O"
*goes into the actual hosting site's file managements, also doesn't work*
"Welp! I'm screwed!"
*researches a freaking day in Google to find a way to fix my issue*
"Finally! It's fixed! =D"

And here's what you need to do if you screw up like I did and didn't know you could mostly ONLY use ASCII (or ISO-8859-1, if you prefer me saying that) characters and not ANSI...
  1. (may differ on each FTP program, I use FileZilla) right-click on the commands on top
  2. hit Enter custom command
  3. enter RNFR “@™¡ñ” (ReName FRom the file name you initially called that folder)
  4. which should then display "Response: 350 RNFR accepted - file exists, ready for destination"
  5. then repeat the process but this time instead write RNTO somethingelse (ReName TO the new name for the folder ;D)
  6. and you should now have the folder renamed to somethingelse, allowing you to modify and delete it again. ^^
For some FTP you have to use ftp> RNFR and ftp>RNTO instead.


If you have to know what I'm good/okay at, I do HTML, CSS, JavaScript, and some PHP as well as MySQL (but also a bit of AJAX) and was into doing XHTML for quite a while. ^^ Though HTML5 and CSS3 have some pretty neat features which I've been looking into. =) I use Notepad++ and enter my code from scratch, just to make me memorize it better. ^^ But I do look at plenty of websites to research for more codes or how to make mine faster, like to get the most out of FOR loops and whatever. =)

Only thing I can't stand is SVG for how long it takes to just make a shape you can easily draw (say... Pikachu's head with ears). >_> Inkscape just showered the image with excess KB of coding that are way too precise (who's ever heard of a 0.0001 pixel?)


So am I allowed to talk here? 'u' I promise to behave. ^-^ ♥ *tries being cute, probably fails miserably*

Megan April 19th, 2017 10:03 AM

Going to be so happy when we finally ditch Delphi 7. Stupid outdated release with a stupid buggy IDE and the more addons I force upon it, the more terrible it turns. And then it doesn't even have a way to force vim keybindings into the editor, let alone use an alternative editor altogether.

*The ramblings of someone who uses Windows/Delphi at work and Linux/C++ at home*

Leviathan April 25th, 2017 2:22 AM

Been thrown headfirst in the lovely world of setting up web servers. 'Course now's the time I have to do this, by myself, when I haven't touched a Linux installation in about 3 years. Been quite a trip, trying to remember everything. Got there in the end, though. o/

Leviathan May 3rd, 2017 1:40 AM

Aye, AWS is such a lovely platform to work with, I must say. Had to set up a database on it for a group project in college back in January, and the place I'm currently working in uses it extensively too.

I just wish I understood more of its features, haha. That Route 53 stuff in particular is new territory to me, but I'm slowly getting there, I suppose. Amazon's documentation has been extremely useful and clear to read, thankfully.

Leviathan May 4th, 2017 6:27 AM

Quote:

Originally Posted by Incineroar (Post 9636262)
I'm hearing lots about AWS, but I'm still really undecided as to what hosting I want to go with. I could get dirt cheap shared hosting, but I'd like to have dedicated hosting and perhaps set up HTTPS as a best practice measure even though I'm not sending any information on the website... At least yet.

Mind recommending a few dirt cheap hosting sites? Thinking of making a personal site, so the cheaper the better. I used a particular host for a project earlier in the year which nearly drove me spare - had a very poor service with lots of downtime.

And Johnny, maybe try using cookies or sessions? Could try storing data in a file, too, if you wish to do so without reading a DB.

Leviathan May 22nd, 2017 7:00 AM

Say, I'm due to start learning about Android development in the fall, with a huge project lurking in the wings that might require some kind of android app integration. Would anyone be able to recommend me some resources/tutorials to look at? I've got that Android Studio IDE installed and I'm thinking of checking out Lynda.com, and maybe Youtube later... No clue what language to use either, but I'm open to suggestions.

string555 July 12th, 2017 4:34 PM

Does anyone want free malwarez? :O

Joking, relax. XD

I've been studying perl for a number of years now, I've barely started on learning C for one of my next daughters. She's going to be a Win10 Keylogger with Rootkit capabilities, for research.

string555 July 14th, 2017 9:43 PM

In hindsight, that was a terrible introduction to this thread. >_<

How about this instead:

I've had an idea for a while now that I've never got a chance to implement. I call it the "Crypto Easter Egg".

The problem with easter eggs in any game is that someone can just pick apart the game's code as soon as it is released and find out any secrets and easter eggs, which IMO defeats the purpose. I believe they should only be found after the player explores almost every corner of the game and stumbles across it by accident.

So, the idea is to take the part of the game's code that has the easter egg and store it in encrypted form. When the player goes to a certain location of the game and does a certain action, a bunch of variables are taken from certain events along with the different characters' stats, and combined into a string. That string is then run through a cryptographic hash and compared to a hash digest embedded in the game's code. If it matches exactly, then that original string, the unhashed one, is converted to bytes and used to decrypt the easter egg code, which of course is then executed.

How does that sound? :D

If my explanation doesn't make enough sense, I can write up a quick and dirty perl script to demonstrate.

string555 July 17th, 2017 3:52 PM

Quote:

Originally Posted by Incineroar (Post 9706210)
Been super busy to reply to pretty much anything haha

In all honesty, depending on what your game's platform is, you can probably get away with system security. But, the thing is that no matter what, people will try reverse-engineering it if they're that committed, or, once one person finds out, it'll get on the internet and everyone will know it. I wouldn't go to that great of a length to try hiding an easter egg, because once it's found and mentioned online, everyone will know about it.

Besides, if all your scripts and text are all unencrypted except for one random portion, it'll basically draw attention to itself because of its nature. If you do all of the text and scripts, once someone decrypts them, then it's found anyway. There's no good way of going about it. It may slow them down for a time, but at the end of the day, it won't really be too much for anyone to do.

That's very true that once someone figures out how to unlock it, it would be all over the internet. It could take some time if enough variables were put into the key, which would make brute-forcing it unreasonable. At the same time, if too little were put into the key, brute-forcing it would be a cakewalk. Also, that would be why the key is stored in the code as a hash digest, the original key would only be used if it's digest matched that one. That way you couldn't pick apart the game's code for the key.

It seems funny if there was an easter egg in a game that nobody could ever unlock, if the key was a ridiculous size and the algorithm was something like RSA... :P

string555 July 24th, 2017 5:24 PM

Quote:

Originally Posted by Incineroar (Post 9711799)
Yeah, at that point you might as well invest in some form of DRM system that allows for game content to be encrypted, then it'll slow them down a bit. In addition, using in-house formats that store content with, say, a different character encoding may also help. As well, try making your build system create obfuscated file names will also slow down RE attempts because they'd have to document the files first.

At that point, why not just make it into a rootkit? XD

Honest August 4th, 2017 8:11 PM

Been meaning to post in here since forever.

Hey guys! I'm Honest, but you can just call me Dipu. I majored undergrad with a degree in Media Studies concentrating in Emerging Media/Web Development, as well as a minor in Computer Science. Currently I work as a software developer trainee. I'm proficient with HTML5, CSS3, JavaScript, JQuery, AngularJS, SQL, and Java. I have also dabbled with C++, Python, and Unix. Also dabbled with C# thanks to Unity. I intend to learn NodeJS and pHp when I can.

Now that the formalities are out of the way, I was wondering if anyone could help me understand something. I was doing some JPA (Java Persistence API), which is essentially manipulating databases with Java. While doing some assertion tests, I ran into this error that I simply could not wrap my mind around. My trainer could not figure it out either (I actually had to remove the test case completely cause I could not figure it out in the 2 days I had). Here are the code.

This is the method from my DBReadCommand class, along with the EntityManagerFactory and EntityManager being used to connect to the database and handle my User entity:
Spoiler:
Code:

private EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("User");

private EntityManager em = emFactory.createEntityManager();

public List<User> listUsers(){

        Query query = em.createQuery("SELECT e FROM User e", User.class);
        List<User> userList = query.getResultList();
        return userList;
}




Here are my write and delete User commands from my DBWriteCommand class
Spoiler:
Code:

private EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("User");

private EntityManager em = emFactory.createEntityManager();

public void writeUser(User user) {
        em.getTransaction().begin();

        em.persist(user);

        em.getTransaction().commit();
}

public void removeUser(String username){
        User retrievedUser = em.find(User.class, username);

        em.getTransaction().begin();

        em.remove(retrievedUser);

        em.getTransaction().commit();
}




And here is my test case that kept failing, with the set-up and teardown (this is JUnit)
Spoiler:
Code:

@Before
public void setUp() throws Exception {
        DBWrite = new DBWriteCommand();
        DBRead = new DBReadCommand();
        if(DBRead.findUser(USERNAME)){
                DBWrite.removeUser(USERNAME);
        }
}

@After
public void tearDown() throws Exception {
        if(DBRead.findUser(USERNAME)){                                //this just checks if the user exists in the DB
                DBWrite.removeUser(USERNAME);
        }
}

@Test
public void testIfDatabaseSizeDecreasesWhenRemovingUser(){
        User testUser = new User(USERNAME, PASSWORD, ROLE);
        DBWrite.writeUser(testUser);
        int expectedValue = DBRead.listUsers().size()-1;

        DBWrite.removeUser(testUser);
        int actualValue = DBRead.listUsers().size();

        assertEquals(expectedValue, actualValue);

}




Now the test case SHOULD pass. But it does not, and it keeps giving me, if I recall correctly, an error saying I'm attempting to delete a null/non-existent entity. What I do know is that after deleting the added user, in the tear down, my findUser method reportedly finds the user in the database, even though he does not exist. So upon the attempted delete within the if-block, it throws an error. Another thing I know is that if I do not use the listUser method, the test compiles and runs just fine.

If anyone happens to know what's going on, I'd greatly appreciate it!

Honest August 6th, 2017 10:26 AM

Quote:

Originally Posted by Incineroar (Post 9723336)
So in looking at your code, have you had a chance to look, in a debugger, at what em.find() is returning in removeUser()? I feel that line is probably the only place that it could possibly fail, especially that it fits in context with the fact that it's trying to delete something nonexistent/null and is still visible when you do the teardown. In addition, are the keys that you're searching by being properly fulfilled? Are there any nulls that could be throwing off results?

Edit: I noticed in your test function where compares sizes that you're passing a full instance of a User to removeUser() yet the function uses a String username as a parameter. Is this intentional?

I'll get back to you on the first part within the week, my source code is at work. Regarding the removeUser() method, that was my mistake just now, it should be USERNAME. Sorry!

Honest August 23rd, 2017 6:09 PM

Quote:

Originally Posted by Incineroar (Post 9737582)
Any updates on this? I'm curious to see what came of this.

Oh I completely forgot to update you guys, sorry!

Sadly, I spent maybe 2 more days on it, but neither me nor my trainers could make heads or tails of the situation. In the end, I scrapped the test and simply used a different variation.

Sorry for the disappointing outcome :'(

string555 September 7th, 2017 4:16 PM

I looked into the next AES competition, called CAESAR. The encryption algorithms submitted have to have a built-in authentication function. Upon looking at the submissions, I noticed one called 'Deoxys'. I thought, must be some kind of coincidence, probably means something else to its authors. Then I saw the previous round of submissions, and there was one called 'Joltik', by the same authors. I knew then that this was no coincidence.

I think that's pretty cool that some fans of Pokemon put in some entries for that contest, and it seemed relevant to put here. Here's hoping one of those entries wins. :D

Here's the submissions for the contest:
https://competitions.cr.yp.to/caesar-submissions.html

Raffy98 September 17th, 2017 11:52 PM

Noob question time.
Hi! I honestly didn't know where to post this, but I thought that this one was the most appropriate place rather than making a new thread.
Anyway, I was looking to start learning how to program smartphone apps, specifically Android apps, because I thought it could be interesting and also useful for my job (they asked me if I could make Android apps and unfortunately I had to say no).
So my question is, any tips for a beginner like me? Some recommended developing environments or languages? Thanks in advance!

Legendary Silke September 19th, 2017 3:44 AM

Since @Incineroar thought that this might be a good place to continue a discussion on the Discord channel, I'll be posting it here.

I've been thinking about Android app ideas, or maybe writing Python for a change, for the first time. Just me trying to learn new things ;)

Right now I've been thinking of a random name generator (perhaps useful for running a tabletop RPG or playing a video game where you can name your character), though I've been a bit on the fence about it...

There's also Python... perhaps there are good resources to getting to know Python. Hopefully it's not much of a stretch coming from C, C++, C#, and Java.

string555 September 22nd, 2017 12:25 AM

I finally learned enough of the necessary ingredients in ANSI C to start making some very basic file encryption programs. For each version, I did a test encrypt/decrypt of a small text file and an image file of about 200kb. Everything was working fine and dandy up till the 6th version, shown here:
Spoiler:

Code:

/*
XORC1.6

Simple file encryption program.
v1.2 Added a variable key and target file.
v1.3 Added an S-box.
v1.4 Added a second key.
v1.5 Changed the sz's and i's variable type to unsigned long long.
Also split encryption and decryption into separate loops for efficiency.
v1.6 Added a second S-box

The purpose was to see how this all works in C.
*/

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

int main( void ) {
        int n, n2, l, l2, ed;
        unsigned long long i, sz;
        int sbE[256], sbD[256], sbE2[256], sbD2[256];
        char k[33], k2[33], f[51];
//Input keys, filename, and mode:
        puts("Enter the key (Max 32char): ");
        scanf("%s", k);
        puts("Enter the 2nd key (Max 32char): ");
        scanf("%s", k2);
        puts("Enter the filename: ");
        scanf("%s", f);
        puts("Enter a '1' for decryption, or any other number for encryption.");
        scanf("%d", &ed);
//Initialize S-box:
        for(i=0; i < 256; i++) {
                sbE[i]=i ^ k[0];
        }
//Create reverse S-box if decrypt mode:
        if (ed == 1) {
                for(i=0; i < 256; i++) {
                        sbD[sbE[i]]=i;
                }
        }
//Initialize S-box 2:
        for(i=0; i < 256; i++) {
                sbE2[i]=i ^ k2[0];
        }
//Create reverse S-box 2 if decrypt mode:
        if (ed == 1) {
                for(i=0; i < 256; i++) {
                        sbD2[sbE2[i]]=i;
                }
        }
//Open file in read/binary mode and grab number of bytes
        FILE *fp;
        if ((fp=fopen(f, "rb")) == NULL) {
                fprintf(stderr, "Error opening file %s in mode 'rb'.\n", f);
                return 0;
        }
        fseek(fp, 0, SEEK_END);
        sz=ftell(fp);
        rewind(fp);
//Allocate memory for plaintext/ciphertext bytes
        char *bytes;
        bytes=malloc(sz);
//Encryption/decryption routine:
        if (ed == 1) {
//Decrypt
                for(i=0, n=0, n2=0, l=strlen(k), l2=strlen(k2); i < sz; i++, n++, n2++) {
                        if (n == l) { n=0; }
                        if (n2 == l2) { n2=0; }
                        bytes[i]=sbD[((sbD2[fgetc(fp)] - k2[n2]) % 256)] ^ k[n];
                }
        } else {
//Encrypt
                for(i=0, n=0, n2=0, l=strlen(k), l2=strlen(k2); i < sz; i++, n++, n2++) {
                        if (n == l) { n=0; }
                        if (n2 == l2) { n2=0; }
                        bytes[i]=sbE2[(sbE[((fgetc(fp)) ^ k[n])] + k2[n2]) % 256];
                }
        }
        fclose(fp);
//Open file in write/binary and output plaintext/ciphertext bytes
        if ((fopen(f, "wb")) == NULL) {
                fprintf(stderr, "Error opening file %s in mode 'wb'.\n", f);
                return 0;
        }
        fwrite(bytes, 1, sz, fp);
        fclose(fp);
        return 0;
}




For the 7th version, all I did was take the repeated code for the S-box initializations and reversing (For decryption) and package them into separate subroutines. That code is shown here:
Spoiler:

Code:

/*
XORC1.7

Simple file encryption program.
v1.2 Added a variable key and target file.
v1.3 Added an S-box.
v1.4 Added a second key.
v1.5 Changed the sz's and i's variable type to unsigned long long.
Also split encryption and decryption into separate loops for efficiency.
v1.6 Added a second S-box.
v1.7 Turned the S-box initialization and reversing into subroutines.

The purpose was to see how this all works in C.
*/

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

void initSbox(int *sbe, char k1);
void revSbox(int *sbd, int *sbe);

int main( void ) {
        int n, n2, l, l2, ed;
        unsigned long long i, sz;
        int sbE[256], sbE2[256], sbD[256], sbD2[256];
        char k[33], k2[33], f[51];
//Input keys, filename, and mode:
        puts("Enter the key (Max 32char): ");
        scanf("%s", k);
        puts("Enter the 2nd key (Max 32char): ");
        scanf("%s", k2);
        puts("Enter the filename: ");
        scanf("%s", f);
        puts("Enter a '1' for decryption, or any other number for encryption.");
        scanf("%d", &ed);
//Generate S-boxes:
        initSbox(sbE, k[0]);
        initSbox(sbE2, k2[0]);
//Make reverse S-boxes if in decrypt mode:
        if (ed == 1) {
                revSbox(sbD, sbE);
                revSbox(sbD2, sbE2);
        }
//Open file in read/binary mode and grab number of bytes:
        FILE *fp;
        if ((fp=fopen(f, "rb")) == NULL) {
                fprintf(stderr, "Error opening file %s in mode 'rb'.\n", f);
                return 0;
        }
        fseek(fp, 0, SEEK_END);
        sz=ftell(fp);
        rewind(fp);
//Allocate memory for plaintext/ciphertext bytes:
        char *bytes;
        bytes=malloc(sz);
//Encryption/decryption routine:
        if (ed == 1) {
//Decrypt:
                for(i=0, n=0, n2=0, l=strlen(k), l2=strlen(k2); i < sz; i++, n++, n2++) {
                        if (n == l) { n=0; }
                        if (n2 == l2) { n2=0; }
                        bytes[i]=sbD[((sbD2[fgetc(fp)] - k2[n2]) % 256)] ^ k[n];
                }
        } else {
//Encrypt:
                for(i=0, n=0, n2=0, l=strlen(k), l2=strlen(k2); i < sz; i++, n++, n2++) {
                        if (n == l) { n=0; }
                        if (n2 == l2) { n2=0; }
                        bytes[i]=sbE2[(sbE[((fgetc(fp)) ^ k[n])] + k2[n2]) % 256];
                }
        }
        fclose(fp);
//Open file in write/binary and output plaintext/ciphertext bytes:
        if ((fopen(f, "wb")) == NULL) {
                fprintf(stderr, "Error opening file %s in mode 'wb'.\n", f);
                return 0;
        }
        fwrite(bytes, 1, sz, fp);
        fclose(fp);
        return 0;
}

void initSbox(int *sbe, char k1) {
        //Initialize S-box:
        int i2=0;
        for(i2=0; i2 < 256; i2++) {
                sbe[i2]=i2 ^ k1;
        }
        return;
}

void revSbox(int *sbd, int *sbe) {
        //Reverse S-box for decryption:
        int i2=0;
        for(i2=0; i2 < 256; i2++) {
                sbd[sbe[i2]]=i2;
        }
        return;
}




I did the same tests, with the same keys, on the same files. It worked perfectly fine for the text file. But here's where it got weird. When I used it on the image file, after decryption, it got corrupted. I restored it from an original copy and tried it several other times with different keys. I carefully examined all my input, it matched exactly between encryption and decryption. So next, I took several other image files of different sizes, the smallest being around 20kb. All of them had the same problem. Then I took another text file of around 10kb and tried it with that, it worked perfectly fine.

Because of these weird inconsistencies, I can't really begin to understand what the problem is, and I'm still pretty new to C programming (I came from mostly perl). I'm in one of those "I'm not sleeping until I figure out the problem" modes. XD

Note: Not sure why it removed everything between the angle brackets in the include statements when posting, must be some kind of whitelist thing going for the BBS. :O

Edit1: So I stared at the code for a good while, it still won't confess its problems. :/

Next, I thought that maybe for some reason the problem was related to the size of the input file. So I made a 30kb text file, 10kb larger than the smallest image file I tried it on. It worked fine. XD

Then, just to try a different file type, I encrypted/decrypted a 9mb mp4 file. Same corruption problem. :/
And just to add to that, the previous 6th version worked perfectly fine on that very same file.

Normally, at this point, I would try peppering the code with debug statements, but I don't think that method will work in this case.

Final Edit: Well, it's been 1 week and I still haven't solved the problem. Instead of repeatedly banging my head against the wall of code, I decided to continue work from the 6th version until I figured it out. I added a loop for variable number of cycles, and a layer of diffusion in the version now known as 'LEA' (Little Encryption Automator). But, I came across another problem that I didn't (And still don't) understand. I'll skip the details on that one, though.

Then, yesterday, I had some free time after work, so I used the computer there to start working on a key schedule. It all worked fine there, so I printed out the page of code. Then today, I typed it up exactly as written, and lol, didn't work on my computer. So much for ANSI C being easily portable... But, it was simple code, so I dissected it thoroughly. I came up with the idea of changing all the int and char arrays to be the matching unsigned char type. That fixed it, though I'm not completely sure why. XD

Then I decided that since it worked for that one, and since I should probably keep everything matching on LEA for when I tie the code into her, I tried the same solution for her. Much lulz ensued as it made her work just fine. I was hoping that this same solution could be applied to xorc7, and so I tried it, but it still has that same problem. I will keep trying to figure it out, but in the meantime, the next step is working more on the key schedule code and then tying it into the next version of LEA. Here is her code for now:
Spoiler:
Code:

/*
LEA v1.0 (Little Encryption Automator)
*/

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

int main( void ) {
        int i2, n, n2, l, l2, ed, cycles, ncycles;
        unsigned long long i, sz;
        int sbE[256], sbD[256], sbE2[256], sbD2[256];
        unsigned char k[33], k2[33], f[51];
//Input keys, filename, and mode:
        puts("LEA: Enter the key (Max 32char): ");
        scanf("%s", k);
        puts("LEA: Enter the 2nd key (Max 32char): ");
        scanf("%s", k2);
        puts("LEA: Enter the filename: ");
        scanf("%s", f);
        puts("LEA: Enter a '1' for decryption, or any other number for encryption: ");
        scanf("%d", &ed);
        puts("LEA: Enter the number of cycles: ");
        scanf("%d", &cycles);
        l=strlen(k);
        l2=strlen(k2);
//Initialize S-box:
        for(i2=0; i2 < 256; i2++) {
                sbE[i2]=i2 ^ k[0];
        }
//Create reverse S-box if decrypt mode:
        if (ed == 1) {
                for(i2=0; i2 < 256; i2++) {
                        sbD[sbE[i2]]=i2;
                }
        }
//Initialize S-box 2:
        for(i2=0; i2 < 256; i2++) {
                sbE2[i2]=i2 ^ k2[0];
        }
//Create reverse S-box 2 if decrypt mode:
        if (ed == 1) {
                for(i2=0; i2 < 256; i2++) {
                        sbD2[sbE2[i2]]=i2;
                }
        }
//Open file in read/binary mode and grab number of bytes
        FILE *fp;
        if ((fp=fopen(f, "rb")) == NULL) {
                fprintf(stderr, "LEA: Error opening file %s in mode 'rb'.\n", f);
                return 0;
        }
        fseek(fp, 0, SEEK_END);
        sz=ftell(fp);
        rewind(fp);
//Allocate memory for plaintext/ciphertext bytes
        unsigned char *bytes;
        bytes=malloc(sz);
        for(i=0; i < sz; i++) {
                bytes[i]=fgetc(fp);
        }
        fclose(fp);
//Encryption/decryption routine:
        if (ed == 1) {
//Decrypt cycle loop:
                for(ncycles=0; ncycles <= cycles; ncycles++) {
                        for(i=0, n=0, n2=0; i < sz; i++, n++, n2++) {
                                if (n == l) { n=0; }
                                if (n2 == l2) { n2=0; }
                                bytes[i]=sbD[((sbD2[bytes[i]] - k2[n2]) % 256)] ^ k[n];
                        }
//Diffusion layer (Decrypt):
                        for(i=(sz - 1); i > 0; i--) {
                                bytes[i] ^= bytes[i-1];
                        }
                }
        } else {
//Encrypt cycle loop:
                for(ncycles=0; ncycles <= cycles; ncycles++) {
//Diffusion layer (Encrypt):
                        for(i=1; i < sz; i++) {
                                bytes[i] ^= bytes[i-1];
                        }
//Main encryption loop:
                        for(i=0, n=0, n2=0; i < sz; i++, n++, n2++) {
                                if (n == l) { n=0; }
                                if (n2 == l2) { n2=0; }
                                bytes[i]=sbE2[(sbE[(bytes[i] ^ k[n])] + k2[n2]) % 256];
                        }
                }
        }
//Open file in write/binary and output plaintext/ciphertext bytes
        if ((fopen(f, "wb")) == NULL) {
                fprintf(stderr, "LEA: Error opening file %s in mode 'wb'.\n", f);
                return 0;
        }
        fwrite(bytes, 1, sz, fp);
        fclose(fp);
        puts("LEA: Encryption/Decryption complete.");
        return 0;
}




Edit X: Okay, so I said that last edit would be in fact, the last, but I had no trouble implementing the key schedule, so I decided to share it. :P

Here it is:
Spoiler:
Code:

/*
LEA v2.0 (Little Encryption Automator)

v2.0 Added a key schedule.
8 cycles recommended for efficiency.
*/

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

unsigned char rotbits(unsigned char ibyte);
void cKISS(unsigned char *k1, unsigned char *k2, unsigned char *k3, int len);

int main( void ) {
        int i2, n, ed, cycles, ncycles, len;
        unsigned long long i, sz;
        int sbE[256], sbD[256], sbE2[256], sbD2[256];
        unsigned char k1[33], k2[33], f[51];
//Input keys, filename, and mode:
        puts("LEA: Enter the key (Max 32char): ");
        scanf("%s", k1);
        puts("LEA: Enter the 2nd key (Max 32char, must be same length as 1st key): ");
        scanf("%s", k2);
        puts("LEA: Enter the filename: ");
        scanf("%s", f);
        puts("LEA: Enter a '1' for decryption, or any other number for encryption: ");
        scanf("%d", &ed);
        puts("LEA: Enter the number of cycles: ");
        scanf("%d", &cycles);
//Get length of initial key times 8:
        len=strlen(k1) * 8;
//Create 1st key schedule:
        unsigned char *k3;
        k3=malloc(len);
        cKISS(k1, k2, k3, len);
//Create 2nd key schedule:
        unsigned char *k4;
        k4=malloc(len);
        for(i2=1; i2 < strlen(k1); i2++) {
                                k1[i2] ^= k1[i2-1];
                        }
        for(i2=1; i2 < strlen(k2); i2++) {
                                k2[i2] ^= k2[i2-1];
                        }
        cKISS(k2, k1, k4, len);
//Initialize S-box:
        for(i2=0; i2 < 256; i2++) {
                sbE[i2]=i2 ^ k3[0];
        }
//Create reverse S-box if decrypt mode:
        if (ed == 1) {
                for(i2=0; i2 < 256; i2++) {
                        sbD[sbE[i2]]=i2;
                }
        }
//Initialize S-box 2:
        for(i2=0; i2 < 256; i2++) {
                sbE2[i2]=i2 ^ k4[0];
        }
//Create reverse S-box 2 if decrypt mode:
        if (ed == 1) {
                for(i2=0; i2 < 256; i2++) {
                        sbD2[sbE2[i2]]=i2;
                }
        }
//Open file in read/binary mode and grab number of bytes
        FILE *fp;
        if ((fp=fopen(f, "rb")) == NULL) {
                fprintf(stderr, "LEA: Error opening file %s in mode 'rb'.\n", f);
                return 0;
        }
        fseek(fp, 0, SEEK_END);
        sz=ftell(fp);
        rewind(fp);
//Allocate memory for plaintext/ciphertext bytes
        unsigned char *bytes;
        bytes=malloc(sz);
        for(i=0; i < sz; i++) {
                bytes[i]=fgetc(fp);
        }
        fclose(fp);
//Encryption/decryption routine:
        if (ed == 1) {
//Decrypt cycle loop:
                for(ncycles=0; ncycles < cycles; ncycles++) {
                        for(i=0, n=0; i < sz; i++, n++) {
                                if (n == len) { n=0; }
                                bytes[i]=sbD[((sbD2[bytes[i]] - k4[n]) % 256)] ^ k3[n];
                        }
//Diffusion layer (Decrypt):
                        for(i=(sz - 1); i > 0; i--) {
                                bytes[i] ^= bytes[i-1];
                        }
                }
        } else {
//Encrypt cycle loop:
                for(ncycles=0; ncycles < cycles; ncycles++) {
//Diffusion layer (Encrypt):
                        for(i=1; i < sz; i++) {
                                bytes[i] ^= bytes[i-1];
                        }
//Main encryption loop:
                        for(i=0, n=0; i < sz; i++, n++) {
                                if (n == len) { n=0; }
                                bytes[i]=sbE2[(sbE[(bytes[i] ^ k3[n])] + k4[n]) % 256];
                        }
                }
        }
//Open file in write/binary and output plaintext/ciphertext bytes
        if ((fopen(f, "wb")) == NULL) {
                fprintf(stderr, "LEA: Error opening file %s in mode 'wb'.\n", f);
                return 0;
        }
        fwrite(bytes, 1, sz, fp);
        fclose(fp);
        puts("LEA: Encryption/Decryption complete.");
        return 0;
}

unsigned char rotbits(unsigned char ibyte) {
//Rotate last bit to first bit
        return (ibyte >> 1) ^ ((ibyte & 1) << 7);
}

void cKISS(unsigned char *k1, unsigned char *k2, unsigned char *k3, int len) {
//C Key Initialize Scheduling Subroutine 1.0
        int i, i2;
        int l=strlen(k1);
        for(i=0, i2=0; i < len; i++, i2++) {
                if (i2 == l) { i2=0; }
                k2[i2] ^= rotbits(k1[i2]);
                k3[i]=k2[i2] ^ k1[i2];
                k1[i2]=rotbits(k1[i2]);
        }
        return;
}




If nothing else, maybe it's interesting to see the development of a (weak) cipher, step by step. :P

Flowerchild October 10th, 2017 10:59 AM

<p>i started to write a discord bot in coffeescript bc i wanted to experiment with discord.js but couldn't stand actually writing js, so now i'm just compiling to it.</p>

Leviathan October 14th, 2017 12:50 PM

I enjoyed tinkering briefly with a discord bot in c# I if I remember correctly? Coulda been C++, been ages since I last looked at it.

Finally got started on android development too. So far, so good, and now I've got to do a dissertation on a shopping list app I've chosen to develop for my final year project.

string555 October 19th, 2017 6:25 PM

Does anyone else actually enjoy the debugging process? As long as it's not someone else's code, I actually like doing it. It's kind of like solving a puzzle that I created on accident. :D

Not to mention that when the bugs are clear and everything works the way you wanted it to, it gives a very good feeling. ^_^

Tsutarja October 19th, 2017 7:02 PM

Debugging is complete hell if you have no idea what's wrong, but something is wrong.

string555 November 1st, 2017 6:56 PM

Quote:

Originally Posted by Tsutarja (Post 9777532)
Debugging is complete hell if you have no idea what's wrong, but something is wrong.

Even worse is when you figure out how to fix the bug, but you have no idea WHY it fixes it. XD

For example, I was recently learning how to play with argc and argv in C. Here's a snippet of the code I finished:
Spoiler:
Code:

int main(int argc, char *argv[]) {
        int i2, n, ed, cycles, ncycles, len;
        unsigned long long i, sz;
        int sbE[256], sbD[256], sbE2[256], sbD2[256];
        unsigned char k1[33], k2[33], f[51];
        if (strcmp(argv[0], "-c")) {
                if (argc < 7) {
                        fprintf(stderr, "LEA: Insufficient arguments.\n");
                        return 0;
                }
                strcpy(k1, argv[2]);
                strcpy(k2, argv[3]);
                if (strlen(k1) != strlen(k2)) {
                        fprintf(stderr, "LEA: Key lengths don't match, exiting program.\n");
                        return 0;
                }
                strcpy(f, argv[4]);
                char *p;
                ed=strtol(argv[5], &p, 10);
                cycles=strtol(argv[6], &p, 10);
        }




So to run this one-line mode, you enter "-c" after the name of the program, allowing you to then write out all the input on the rest of the line in one go. During a test, I printed argv[0] and argv[1], which showed that the first argument was the name of the program, and the second was "-c". However, the program would not want to jump into that if statement, going instead to the else (Not shown). So, for some reason I decided to change that part to try and use argv[0] instead, on a whim. It then successfully jumps into the if block. Now, I know damn well that argv[0] contains the name of the program, because as I stated earlier, I printed out the first 2 arguments and saw that to be true.

So why does it now work as if argv[0] contains "-c"? I have no psyducking clue... XD

Venia Silente November 2nd, 2017 8:13 PM

Quote:

Originally Posted by string555 (Post 9786398)
Even worse is when you figure out how to fix the bug, but you have no idea WHY it fixes it. XD

For example, I was recently learning how to play with argc and argv in C. Here's a snippet of the code I finished:
Spoiler:
Code:

int main(int argc, char *argv[]) {
        int i2, n, ed, cycles, ncycles, len;
        unsigned long long i, sz;
        int sbE[256], sbD[256], sbE2[256], sbD2[256];
        unsigned char k1[33], k2[33], f[51];
        if (strcmp(argv[0], "-c")) {
                if (argc < 7) {
                        fprintf(stderr, "LEA: Insufficient arguments.\n");
                        return 0;
                }
                strcpy(k1, argv[2]);
                strcpy(k2, argv[3]);
                if (strlen(k1) != strlen(k2)) {
                        fprintf(stderr, "LEA: Key lengths don't match, exiting program.\n");
                        return 0;
                }
                strcpy(f, argv[4]);
                char *p;
                ed=strtol(argv[5], &p, 10);
                cycles=strtol(argv[6], &p, 10);
        }




So to run this one-line mode, you enter "-c" after the name of the program, allowing you to then write out all the input on the rest of the line in one go. During a test, I printed argv[0] and argv[1], which showed that the first argument was the name of the program, and the second was "-c". However, the program would not want to jump into that if statement, going instead to the else (Not shown). So, for some reason I decided to change that part to try and use argv[0] instead, on a whim. It then successfully jumps into the if block. Now, I know damn well that argv[0] contains the name of the program, because as I stated earlier, I printed out the first 2 arguments and saw that to be true.

So why does it now work as if argv[0] contains "-c"? I have no psyducking clue... XD

Because you are using strcmp wrong, actually >:)

You see, strcmp does not return a bool value for comparison, so you should not use it in an if unless you explicitly compare to a result. strcmp returns zero aka "false" if the strings you are comparing are equal, whereas you are looking for a "true" value, which is any nonzero value - when the strings ae different.

Your line should read

Code:

        if (0 == strcmp(argv[1], "-c")) {


That it worked out well for argv[0] might have been mostly luck given that the hyphen in "-c" comes before any other valid character in the name of your program and thus "-c" always compared more "favorably". If your program name was started with a dot assuming the filesystem allows it, you'd see how it fails.


All times are GMT -8. The time now is 11:22 PM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.