C3rd
Gradle Project Tests
Posted: 6 Jun 2020, 9:59am - SaturdayThe Error:
gradle Caused by: org.junit.platform.commons.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
I've been writing tests on my java gradle project and I thought the tests was running every time I compile. I'm using IntelliJ IDEA and when I right click the test folder and `Run All Tests`, seems to work well.
Then I found out that it wasn't running at all when I ran the report.
"Five hours later..." I almost gave up and decided to go back to maven. Then thought maybe I will search the error one last time. Landed to this page: https://discuss.gradle.org/t/gradle-4-6-and-junit-5/26061 -- then decided to give one last try. So I change my build.gradle
plugins { id 'java' id 'project-report' } group 'nz.camilord.alphaone.sample' version '1.0.0-SNAPSHOT' sourceCompatibility = 11 targetCompatibility = 11 repositories { mavenCentral() } dependencies { compile 'postgresql:postgresql:9.0-801.jdbc4' compile 'com.google.code.gson:gson:2.8.0' testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.2' //testCompile 'junit:junit:4.13' }
to this new configuration:
plugins { id 'java' id 'project-report' } group 'nz.camilord.alphaone.sample' version '1.0.0-SNAPSHOT' sourceCompatibility = 11 targetCompatibility = 11 repositories { mavenCentral() } dependencies { compile 'postgresql:postgresql:9.0-801.jdbc4' compile 'com.google.code.gson:gson:2.8.0' testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.2' testCompile 'org.jetbrains.spek:spek-junit-platform-engine:1.0.89' testRuntime 'org.junit.jupiter:junit-jupiter-engine' //testCompile 'junit:junit:4.13' } test { useJUnitPlatform() } configurations { externalLibraries compile.extendsFrom (externalLibraries) }
... and the result is a success! It works!
How do I backup my e-mails?
Posted: 26 Mar 2017, 10:03am - SundayVisual C# .Net and rsync
Posted: 28 Oct 2015, 1:40am - WednesdayDuck Scraper for fb
Posted: 7 Dec 2012, 11:10am - Friday- Internet Explorer 7 or latest version
- .Net Framework 4.0
Developer's MySQL Auto-backup for Windows
Posted: 18 Sep 2011, 12:49pm - Sunday- Download [download id="25"]
- Download at SEOfart.com -> dmab_v1.0.0.56.exe
Pingering - Free Ping Utility Tool for SEO
Posted: 27 Jan 2011, 18:02pm - Thursdaydev-C++: Bank Queue Simulation using Graphic
Posted: 8 Sep 2010, 0:18am - WednesdayHere's the Demo Executable file: [download id="15"]
Source Code: [download id="16"]
Prototype POS System - Transparent GUI
Posted: 23 Apr 2010, 16:48pm - Friday- As you create a form as Form1, go to Form1 properties and set TransparencyKey to Black.
- Then set your Backcolor of your form to Black.
- In Photoshop or any image editing tools, create an GUI or layout design then save as PNG format.
- In Form1 properties, set BackgroundImage and select the PNG image you created from Photoshop or other image editing tools.
- Set also the FormBorderStyle to None and Opacity to 95%.
- Then run your project. You'll see the transparency works well. :)
Visual C#: Handling X button (top-right)
Posted: 7 Dec 2009, 10:21am - Mondayprivate const int CP_NOCLOSE_BUTTON = 0x200; protected override CreateParams CreateParams { get { CreateParams myCp = base.CreateParams; myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON; return myCp; } }Add confirmation if window closing or closed... Insert this code to Main form or the Form1.cs...
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }Insert this to Form1.Designer.cs...
this.Closing += new System.ComponentModel.CancelEventHandler( this.frmCCS_Closing);
IntelliJ IDEA + Java versions + Maven + Gradle
Posted: 5 Jun 2020, 11:57am - FridayOk, I have been writing java codes from quite some time now. And most common I forgot to set are the following areas to configure in IntelliJ IDEA.
- Project Structure - always set both Project SDK and Project Language Level
2. SDK - you have to define the JDK home path to use in your project
3. Java bytecode - ensure that you set the Project bytecode version and add your project in per-module bytecode version and define the target bytecode version.
4. Maven - pom.xml file
5. Gradle - build.gradle file
And if you fail to configure these versions, you'll end up seeing RED texts/icons.
MD5 File Hash for C# and PHP
Posted: 14 Aug 2016, 10:06am - Sundaypublic static string md5_file(string fileName) { FileStream file = new FileStream(fileName, FileMode.Open); MD5 md5 = new MD5CryptoServiceProvider(); int length = (int)file.Length; // get file length byte[] buffer = new byte[length]; // create buffer int count; // actual number of bytes read int sum = 0; // total number of bytes read // read until Read method returns 0 (end of the stream has been reached) while ((count = file.Read(buffer, sum, length - sum)) > 0) sum += count; // sum is a buffer offset for next reading byte[] retVal = md5.ComputeHash(buffer); file.Close(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < retVal.Length; i++) { sb.Append(retVal[i].ToString("x2")); } return sb.ToString(); }For PHP:
<?php echo md5_file($filename_with_fullpath); ?>Hope this helps... Thanks to: http://stackoverflow.com/questions/15705676/different-md5-file-hash-in-c-sharp-and-php
QVNZ Viewer (ASC file viewer)
Posted: 3 Aug 2015, 23:57pm - MondayZendify: windows application to auto-populate to the host file and httpd.conf for ZendFramework Projects
Posted: 22 Apr 2012, 13:30pm - SundayGambas 2.x in Ubuntu
Posted: 12 Aug 2011, 16:49pm - Friday
So after installation, as a first app -- the "Hello World!". so I start creating a new project and test typing lil' codes. Coding results below;
[caption id="attachment_574" align="aligncenter" width="576" caption="GAMBAS First App"][/caption]
Conclusion: GAMBAS is just like MS Visual Basic with some little differences in coding. Hope GAMBAS will be fully developed and become mature, with this Linux Desktop Application Developer will raise (and I want to be one of the developers! hahahaha...).
Comments: I like GAMBAS.. so cute! hahahahaha... want to explore more about this software.
For more information about GAMBAS, please visit http://gambas.sourceforge.net/en/main.html
Epoch Time
Posted: 18 Oct 2010, 21:44pm - MondayWhat is epoch time?
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1-1-1970), but 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038 (known as the Year 2038 problem or Y2038).Human readable time | Seconds |
1 minute | 60 seconds |
1 hour | 3600 seconds |
1 day | 86400 seconds |
1 week | 604800 seconds |
1 month (30.44 days) | 2629743 seconds |
1 year (365.24 days) | 31556926 seconds |
How to get the current epoch time in ...
Convert from human readable date to epoch
Perl | Use these Perl Epoch routines |
PHP | mktime(hour, minute, second, month, day, year) |
Ruby | Time.local(year, month, day, hour, minute, second, usec ) (or Time.gm for GMT/UTC input). To display add .to_i |
Python | import time first, then int(time.mktime(time.strptime('2000-01-01 12:34:00', '%Y-%m-%d %H:%M:%S'))) - time.timezone |
Java | long epoch = new java.text.SimpleDateFormat ("dd/MM/yyyy HH:mm:ss").parse("01/01/1970 01:00:00"); |
VBScript/ASP | DateDiff("s", "01/01/1970 00:00:00", time field) |
MySQL | SELECT unix_timestamp(time) Time format: YYYY-MM-DD HH:MM:SS or YYMMDD or YYYYMMDD
More on using Epoch timestamps with MySQL |
PostgreSQL | SELECT extract(epoch FROM date('2000-01-01 12:34'));
With timestamp: SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08');
With interval: SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', time field) |
JavaScript | use the JavaScript Date object |
Unix/Linux Shell | date +%s -d"Jan 1, 1980 00:00:01" Replace '-d' with '-ud' to input in GMT/UTC time. |
Convert from epoch to human readable date
Perl | Use these Perl Epoch routines |
PHP | date(output format, epoch); Output format example: 'r' = RFC 2822 date |
Ruby | Time.at(epoch) |
Python | import time first, then time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(epoch)) Replace time.localtime with time.gmtime for GMT time. |
Java | String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000)); |
VBScript/ASP | DateAdd("s", epoch, "01/01/1970 00:00:00") |
MySQL | from_unixtime(epoch, optional output format) The default output format is YYY-MM-DD HH:MM:SS more ... |
PostgreSQL | PostgreSQL version 8.1 and higher: SELECT to_timestamp(epoch); Older versions: SELECT TIMESTAMP WITH TIME ZONE 'epoch' + epoch * INTERVAL '1 second'; |
SQL Server | DATEADD(s, epoch, '1970-01-01 00:00:00') |
Microsoft Excel | =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other timezones: =((A1 +/- timezone adjustment) / 86400) + 25569. |
Crystal Reports | DateAdd("s", {EpochTimeStampField}-14400, #1/1/1970 00:00:00#) -14400 used for Eastern Standard Time. See Timezones. |
JavaScript | use the JavaScript Date object |
Unix/Linux Shell | date -d @1190000000 Replace 1190000000 with your epoch, needs recent version of 'date'. Replace '-d' with '-ud' for GMT/UTC time. |
PowerShell | Function get-epochDate ($epochDate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochDate)) } , then use: get-epochDate 1279152364 . Works for Windows PowerShell v1 and v2 |
Other OS's | Command line: perl -e "print scalar(localtime(epoch))" (If Perl is installed) Replace 'localtime' with 'gmtime' for GMT/UTC time. |
Algorithm: Graphic Sort
Posted: 8 Aug 2010, 16:14pm - Sunday- Bubble sort
- Selection sort
- Insertion sort
- Quick sort
Visual C#: Detect Conflict Schedule
Posted: 18 Jan 2010, 16:55pm - MondayIf you want to download the whole code, link below and enjoy... Do not practice the copy and paste! :) Download: [download id="6"]// sample conflict detection (defined) [start] DateTime d = new DateTime(2010, 1, 13); richTextBox1.Text = DateTime.Now.ToLongDateString() + " = " + d.ToLongDateString() + "\n"; if (DateTime.Now.CompareTo(d) > 0) { richTextBox1.Text += "true\n" + DateTime.Now.CompareTo(d).ToString(); } else { richTextBox1.Text += "false\n" + DateTime.Now.CompareTo(d).ToString(); } richTextBox1.Text += "\n\n"; DateTime dx = DateTime.Now; //MessageBox.Show(dx.Hour.ToString()); DateTime[] dt = new DateTime[4]; // enrolled schedule dt[0] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 8, 0, 0); dt[1] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0); // adding new schedule dt[2] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0); dt[3] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 10, 0, 0); // checking schedule conflict if (((dt[0].CompareTo(dt[2]) < 0) && (dt[1].CompareTo(dt[2]) > 0)) || (dt[0].ToShortTimeString() == dt[2].ToShortTimeString())) { richTextBox1.Text += dt[0].ToShortTimeString() + " - " + dt[1].ToShortTimeString() + " against " + dt[2].ToShortTimeString() + " - " + dt[3].ToShortTimeString() + "\nResult: CONFLICT"; } else { richTextBox1.Text += dt[0].ToShortTimeString() + " - " + dt[1].ToShortTimeString() + " against " + dt[2].ToShortTimeString() + " - " + dt[3].ToShortTimeString() + "\nResult: NO CONFLICT"; } // sample conflict detection (defined) [end]
C# WebRequest: Headers pitfall
Posted: 4 Jun 2020, 6:36am - ThursdayI have written my own WebRequest wrapper and it took me ages why I am getting a response of bad request. Hours of debugging, I realize that I have overwritten my Content-Type header with my Authentication-Authorization entries.
the issue:
WebRequest request = WebRequest.Create(url);
request.Method = method_request;
request.ContentType = "application/x-www-form-urlencoded";
/**
* dont add content-type header on authenticate
*/
if (!url.Contains("/authenticate"))
{
WebHeaderCollection whc = new WebHeaderCollection();
whc.Add("Auth-username", authorizationEntity.getUsername());
whc.Add("Auth-session-key", authorizationEntity.getSessionKey());
request.Headers = whc;
}
if (method_request.ToUpper() == "POST")
{
Stream stream = request.GetRequestStream();
byte[] postArray = Encoding.UTF8.GetBytes(flatten_post_data);
stream.Write(postArray, 0, postArray.Length);
stream.Close();
}
string Result;
try
{
Console.WriteLine(request.Headers.ToString());
StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream());
Result = sr.ReadToEnd();
} catch(WebException e)
{
Console.WriteLine(e.Message);
Result = "[]";
}
the correct approach:
WebRequest request = WebRequest.Create(url);
request.Method = method_request;
/**
* dont add content-type header on authenticate
*/
if (!url.Contains("/authenticate"))
{
WebHeaderCollection whc = new WebHeaderCollection();
whc.Add("Auth-username", authorizationEntity.getUsername());
whc.Add("Auth-session-key", authorizationEntity.getSessionKey());
request.Headers = whc;
}
request.ContentType = "application/x-www-form-urlencoded";
if (method_request.ToUpper() == "POST")
{
Stream stream = request.GetRequestStream();
byte[] postArray = Encoding.UTF8.GetBytes(flatten_post_data);
stream.Write(postArray, 0, postArray.Length);
stream.Close();
}
string Result;
try
{
Console.WriteLine(request.Headers.ToString());
StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream());
Result = sr.ReadToEnd();
} catch(WebException e)
{
Console.WriteLine(e.Message);
Result = "[]";
}
So that's it. lesson learn! LOL
Facebook Messenger Desktop
Posted: 13 Jan 2016, 2:36am - Wednesday- [download id="45"]
- FacebookMessenger.exe
Visual C# Express 2010 + Firebird SQL
Posted: 29 May 2013, 2:10am - Wednesday- Firebird .NET Provider
- Visual C# Express 2012
private void Form1_Load(object sender, EventArgs e) { FbConnection con = new FbConnection("User=SYSDBA;" + "Password=masterkey;" + "Database=" + currentDir + "\\vshb.fdb;" + "DataSource=127.0.0.1;" + "Port=3050;" + "Dialect=3;" + "Charset=UTF8;"); try { con.Open(); FbTransaction t = con.BeginTransaction(); t.Commit(); FbCommand cmd = new FbCommand("SELECT * FROM \"Bank_Branches\"", con); FbDataReader reader = cmd.ExecuteReader(); textBox1.Text = "Ref. No.\t\tBranch\t\t\t\n"; while (reader.Read()) { textBox1.AppendText(reader.GetValue(0) + "\t\t\t" + reader.GetValue(3) + "\n"); } reader.Close(); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }---- Sample Source: [download id="38"]
Visual C# Upload File/Image via PHP with Squid-Cache in the Network
Posted: 27 Jan 2012, 1:10am - Friday- An exception occurred during a WebClient request.
- The remote server returned an error: (417) Expectation failed.
public void uploadFile() { try { // decleration of webclient ServicePointManager.Expect100Continue = false; System.Net.WebClient webby = new System.Net.WebClient(); //initiate credentials webby.UseDefaultCredentials = false; webby.Credentials = new NetworkCredential("anonymous", ""); //add headers webby.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.832)"); webby.Headers.Add("Content-Type", "binary/octet-stream"); //initiate upload file Byte[] result = webby.UploadFile("http://120.0.0.1/upload.php", "POST", @filename); string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); MessageBox.Show(s); webby.Dispose(); } catch (Exception) { // do nothing... MessageBox.Show("Upload failed!"); } }So far, it works fine with me and satisfied of my solution. Hope this will help your problem too... :)
SEO Fart | XML-RPC Ping Tool
Posted: 4 Aug 2011, 6:31am - ThursdayXML-RPC Ping Tool - A made-easy tool that poke Search Engines via ping service websites that your blog or website has been updated. Capable of mass URL pinging and scheduled URL pinging to make your SEO tasks easy and fast.However, in the office the application is for free but to other people, its for sale. Sweat and effort must be paid of course. :)
Link List
Posted: 2 Oct 2010, 12:56pm - Saturday- Swapping a Link List elements
- Search and Delete an elements from Link List
- [download id="17"]
- [download id="18"]
dev-C++ : Bubble Sort with Graphic Plotting
Posted: 24 Jul 2010, 21:01pm - Saturday- [download id="12"]
- [download id="10"]
- [download id="11"]
Visual C#: Retrieving Image (BLOB) from MySQL database
Posted: 14 Dec 2009, 15:48pm - Monday- idsystem_database.sql.zip - the dump file of MySQL database; import this SQL file before running the project
- the rest of the files are the project sample files
MySqlConnection myConnection = new MySqlConnection(myConnString); string testQuery = "SELECT sp.studePhoto, s.firstName, s.lastName FROM students AS s, student_photos AS sp WHERE s.id = sp.studentID"; MySqlCommand myCommand = new MySqlCommand(testQuery, myConnection); myConnection.Open(); MySqlDataReader myReader = myCommand.ExecuteReader(); FileStream fs; // Writes the BLOB to a file (*.jpg). BinaryWriter bw; // Streams the BLOB to the FileStream object. int bufferSize = 100; // Size of the BLOB buffer. // The BLOB byte[] buffer to be filled by GetBytes. byte[] outbyte = new byte[bufferSize]; long retval; // The bytes returned from GetBytes. long startIndex = 0; // The starting position in the BLOB output. while (myReader.Read()) { DateTime tmp = new DateTime(); tmp = DateTime.Now; // Create a file to hold the output. string filename = camilordMD5(tmp.ToLongDateString().ToString() + tmp.ToLongTimeString().ToString()) + ".jpg"; string dest = Directory.GetCurrentDirectory() + "/" + filename; fs = new FileStream(dest, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); // Reset the starting byte for the new BLOB. startIndex = 0; // Read the bytes into outbyte[] and retain the number of bytes returned. //myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); retval =(long) myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); lblName.Text = myReader.GetString(1) + " " + myReader.GetString(2); // Continue reading and writing while there are bytes beyond the size of the buffer. while (retval == bufferSize) { bw.Write(outbyte); bw.Flush(); // Reposition the start index to the end of the last buffer and fill thebuffer. startIndex += bufferSize; retval = myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); } pictureBox1.ImageLocation = Directory.GetCurrentDirectory() + "/test.jpg"; //pictureBox1.Image = retval; // Write the remaining buffer. bw.Write(outbyte, 0, (int)retval - 1); bw.Flush(); // Close the output file. bw.Close(); fs.Close(); }