Quantcast
Channel: DaniWeb Code Topics
Browsing all 225 articles
Browse latest View live

Getting current time in 12 hour format

This code snippet can be used to get the current time in 12 hour format using JS

View Article


Force CSS to load if it does not

Sometimes a css file wont load because of a slow connection or a conflict between scripts (or just any other reason). This specially problematic on mobile websites (looking at you IOS) where many...

View Article


Empty text boxes on focus if they have an initial value

Hi, I thought I'd share this with you. If you want all fields on a web form to be emptied of ther initial value (if any) on focus and filled again with the initial value on blur. Works with jquery.

View Article

Graphing Line on Coordinate Plane

This is a pretty darn simple snippet that I learned from a site (don't remember the name). This is just the working Javascript which i managed to "easily" replicate :P Hopefully this will be useful...

View Article

Introducing seamless guesswork in JavaScript

Determine if a namespace/variable-name exists Check for namespace existence in your environment variables and objects before writing to them. Guess if "Book1.chapter22.paragraph37" exists without...

View Article


JavaScript String.format

Hi all. This is somewhat the equivalent of .NET String.Format(String, Args); Usages: 'Hello {0}'.format('DaniWeb!'); String.format('{0} {1} {2}', 'Hi', 'Again', 'Good Fella'); String.format('Hello...

View Article

Getting path name of working directory

Some time ago, I needed to know the pathname of my running application, in order to create a temporary file. As it seems ther are alot more options than I thought. So I applied all I could find in...

View Article

Building a dynamic context menu in a C# forms application

This is easy! But I admit, it can be rather confusing at first if you also take the old style MenuItem stuff into account. I hope my code is as clear as possible. If not please let me know. To test...

View Article


creating a SuDoKu puzzle generator

I know that this probably has been done by someone, but I want to learn how to do this using VB 2010 express. I cannot seem to get the numbers to stay in the text boxes that they are dropped in. The...

View Article


i need help with a program in java

i have to write a code that has a random number generated between 1-100 and the user has the choice to keep the number, discard the number and quit the program. and when the user quits the program...

View Article

Converting various video formats to mp4

I have a Chromecast that I use to stream video from my laptop to our TV. It works great, however, until VLC (Videolan) releases their promised upgrade with Chromecase support, I am limited to...

View Article

Probability and Coin Tossing

Here's an interesting little scenario. You get challenged to a game of coin toss. Both players pick a sequence of coin toss results (heads or tails). The coin is repeatedly tossed until the sequence...

View Article

centering the logo doesnt work heeeelp

I have a problem with the CSS for the logo. I want my logo to be in the middle horizontaly every time but my logo isnt aligned with the centered image in the backgroundand, the logo isnt right in the...

View Article


How to detect a form being minimized on Windows 10

Hey guys, does anyone know how to do this? Here is my current code that will not work. I have tried everything that I know how to make this work to no avail. This is under form1_load. Any help would...

View Article

help with code error

void Halt (); void Reply (const char * num,uint8_t stat); { this is the error message for this code 7|error: 'uint8_t' has not been declared 9|error: expected unqualified-id before '{' token

View Article


Farmer crossing river with wolf, duck, bag of corn

This snippets contains a python program to find a shortest solution to the problem of the farmer who whishes to cross a river. The boat can only contain two things, including the rower. The farmer...

View Article

Simple Example of a Genetic Algorithm

A while back I came across an article that mentioned genetic algorithms. For those unfamiliar with the term, simply put, rather than finding a solution to a problem by iterating over all possible...

View Article


error display when code runs

when the console displays the "StudentAns" I get weird characters instead of the actual answer. ///////////////////////////////////////////////////////////// this is the files CorrectAnswers.txt A D B...

View Article

Getting the “after root URL” with PHP

I found myself starting to answer a question that I have answered many times , so I thought why not making a code snippet and just reference this. This is a short code snippet only to demonstrate how...

View Article

Bytecode VM Implemented in Golang

The GitHub Repo is here. This was part of a contest with someone I met on Omegle. The goal was to see who's VM could run a set of example app the fastest, the catch: We had about 24 hours to implement...

View Article
Browsing all 225 articles
Browse latest View live


Latest Images