jymden.com


  • Convert seconds to days, hours, minutes and seconds

    Converting seconds into days, hours, minutes and seconds int days = secondsTotal / 60 / 60 / 24; int hours = (secondsTotal / 60 / 60) % 24; int minutes = (secondsTotal / 60) % 60; int seconds = secondsTotal % 60;

    read more…

  • (C#) Confirmation when closing a form

    Add an event handler for Form Closing and use this code. This is a really simple solution. [c language=”#”] private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("Are you sure?", "Close application", MessageBoxButtons.YesNo) == DialogResult.Yes) e.Cancel = false; else e.Cancel = true; } [/c]

    read more…

  • Simple function to see if a number is Even or Odd.

    Sometimes you need to check if a number is even or odd. A simple way to do this is using the modulus operator (the %-sign). It will calculate and return the remainder when dividing a value with another value. So how do you use that to find out if a number is even or odd?…

    read more…

  • (C#) Scroll to bottom of a textbox

    Short snippet: [c language=”#”] textBox.SelectionStart = textBox.TextLength; textBox.ScrollToCaret(); [/c]

    read more…

  • (PHP) Simple e-mail contact form.

    A simple contact form, just for reference. Will add more info later on… [php] <?php if (isset($_POST[‘submit’])) { $name = $_POST[‘name’]; //name of sender $email = $_POST[’email’]; //e-mail of sender $email = stripslashes($email); $subject = $_POST[‘subject’]; //e-mail subject $subject = str_replace(array("\r\n","\r","\n"), "", $subject); //remove any linebreaks to keep from code injections $message = $_POST[‘message’]; //…

    read more…

  • A couple of principles when learning how to code.

    Principle 1. Always have a clear image of what you want to do BEFORE you start writing your code. Then break it down in logical instructions – making an algorithm.  An algorithm is a step by step instruction on how to solve a specific problem. You might think of it as a recipe. If you…

    read more…

  • Hide elements with radio buttons

    Sometimes you want to show or hide certain elements of a form, depending on the selection of a radiobutton.   I am by no means any javascript ninja, but this is one simple way I came up with:  This could apply to any element. For example, you could put a whole bunch of elements in…

    read more…

  • Hide elements with checkbox

    This is a slightly edited version of this post. Just to make it work with a checkbox instead of radio buttons.    

    read more…

  • Convert MySQL timestamp to PHP date

    If you save your date in the format of timestamp in your MySQL database, and want to output it like this: [php] $result = mysql_query("SELECT * FROM articles"); $row = mysql_fetch_array($result); $date = $row[‘timestamp’]; echo $date; [/php] Your date come out looking something like this: 2011-01-30 20:54:12 So it’s formated like YYYY-MM-DD HH:MM:SS But what…

    read more…

  • (PHP) How to make a simple gallery

    This is just a VERY basic gallery that you can modify to suit your needs. For example you could add columns in the database and store more info about the images (date, size, tags etc.). You could very easily make the output use Lightbox or similar images viewers. And you could of course do a…

    read more…

algorithm (11) android (12) app (8) array (4) C# (6) coding (5) computer science (3) css (4) csv (2) dart (2) database (6) date (2) eloquent (3) form (5) graphics (2) gui (5) html (14) html5 (2) https (2) images (2) java (9) javascript (12) jquery (2) laravel (13) log (2) logic (4) math (4) mvc (2) mysql (9) orientation (2) php (24) queries (1) query (1) replace (2) screen (4) server (2) snippet (4) sorting (2) sql (3) string (2) time (2) tutorial (4) ui (3) validation (2) visual studio (3)