10 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

For those who are afraid of lycanthropes and full moons, here is a way to figure out the phase of the moon.

Member Avatar for Sichen
2
5K
Member Avatar for vegaseat

Some folks go on vacation around the Easter holidays, so it would be nice to know when Easter happens in the years ahead. I had this as a Python snippet in my "oldies, but goodies" file and translated it to Go. It was actually quite easy in this case, and …

Member Avatar for vegaseat
0
946
Member Avatar for ddanbe

OK I know the DateTime structure is very good at doing this. But if you ever wanted to design your own calendar, or just wanted to know how things are possibly done, this could be a handy function. Enjoy.

Member Avatar for xrjf
0
2K
Member Avatar for TrustyTony

I did code for challenge that I saw posted for C# by deceptikon: http://www.daniweb.com/software-development/csharp/threads/479304/coding-challenge-string-to-date Here it is. Of course normally the code would be without prints and put in function, but this is enough for now for me. There could also be normalization from '/' separated form not producing ambiguous …

1
267
Member Avatar for jnawrocki
Member Avatar for JJCollins
Member Avatar for vegaseat

Is it Mother Date and Father Time? Any way, getting all the different date and time displays working can be imperturbably perplexing at times. You take a look at it in this Windows Console Application.

Member Avatar for Tsawm
0
913
Member Avatar for TrustyTony

To be more clear, I post this 'unnecessary optimization' of Vegaseat's code in new thread instead of end of old one. Just to show that this is even simpler than [URL="http://www.daniweb.com/software-development/python/code/363346/1554115#post1554115"]checking if given day is first weekday of the month[/URL].

Member Avatar for TrustyTony
0
1K
Member Avatar for TrustyTony

Here tool functions, which came up during discussions earlier. Expanded slightly, added elimination of traceback prints by try..except. Added dd.mm.yy routine as that is format in my home country Finland. Optimized docstring beginnings to be informative in editor tooltip (at least IDLE shows, but code must be run or imported …

Member Avatar for TrustyTony
1
951
Member Avatar for Alxandr

This is a simple code-snippet that can be used to parse dates with javascript. It's setup to use European dates (dd.mm.yyyy | dd/mm/yyyy | dd,mm,yyyy), but it can easily be setup to use american dates as well (mm/dd/yyyy etc), to do so simply replace "$1" with "$2" and "$2" with …

0
322

The End.