super short folder check in C#
Checking existence of a folder is pretty simple but sometimes I forget the correct function to use 😛 bool exists = System.IO.Directory.Exists(@"c:\myPath");
baranputting an avatar in the corner of another image in PHP
This is for fun and a gem if needed. <?php error_reporting(E_ALL); // LOCATION OF THE IMAGES (COULD COME IN FROM $_GET URL STRING) $original = 'path/to/image.png'; $overlay = 'path/to/another/image.png'; // READ THE IMAGE AND THE OVERLAY FILE // MAN PAGE http://php.net/manual/en/function.imagecreatefrompng.php $im = [...]
baransize/length of DateTime and truncation of DateTime to 8 bytes
I found this code in my backups and apparently, I needed to truncate C# DateTime at some time. Probably, it wasn’t a good idea from the start but maybe, there was a last resort scenario. Here you go: class Program { static void Main(string[] args) { DateTime dt = DateTime.Now; long time_t = DateTimeToTimeT(dt); [...]
baranUnit Test and Load Test in VS2010
While I was digging my old backups, I found this article and I am putting as it is. I couldn’t find the author and if the authoer contacts me, I will give his/her credits. Visual Studio .NET 2010 Unit Testing Visual Studio provides a template for creating unit test projects. The projects can have the following types of tests: [...]
baranHiding an executable’s window when that executable starts to process in C#
I found this old C# code in one of my old backups. It was the case I wanted to hide an executable’s window and that executable has no relation with C# btw. It has a window that i want to hide with my C# code. Here you go. [DllImport("User32")] private static extern int ShowWindow(IntPtr handle, int nCmdShow); private const int [...]
baranlooper in MSSQL
Following this looper case, http://www.barantopal.com/technology/looper-in-c/ Now, out of curiosity, I tried to solve this in MSSQL. ID ColX 1 3 2 3 3 6 4 5 5 2 6 2 7 9 9 11 10 1 11 13 13 14 14 12 15 19 17 18 19 20 20 16 21 22 22 21 23 23 24 23 The following SQL snippet is not the solution but it is too late here and I need to sleep 🙂 I [...]
baranlooper in C#
While I was checking my old machine, I found out a “great” implementation. Given the two lists: List1 List2 1 3 2 3 3 6 4 5 5 2 6 2 7 [...]
baransize of time_t out of the blue
The output of the following program heavily depends on your architecture: # include <stdio.h> # include <iostream> # include <time.h> using namespace std; size_t getPtrSize( char *ptr ) { return sizeof( ptr ); } int main() { time_t lt; lt = time(NULL); cout << "Date: " << ctime(<) << endl; cout [...]
baranconvert a disk from FAT32 to NTFS without formatting the disk
start->run-> cmd type: convert drive_letter: /fs:ntfs
baran