[Solved] JRebel can’t reload jsp in netbeans of spring boot project

JRebel can’t reload jsp in netbeans of spring boot project, asked in jrebel forum but seems no one can answer. I finally found a way to fix it. Don’t execute the “spring-boot:run” goal, directly run your main class, this make jrebel able to reload jsp/css/class, just tested. No matter you put your static files in src/main/webapp or src/main/resources, it just works.

dont touch the jrebel.xml

read count : 36

SQL to convert all tables from MyISAM to InnoDB

This is the SQL to convert all tables to InnoDB, relace the word to your database name, then run the output again.

SELECT CONCAT('ALTER TABLE `', TABLE_SCHEMA, '`.', TABLE_NAME,' ENGINE=InnoDB;')
FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'DBNAME' AND ENGINE = 'MyISAM' AND TABLE_TYPE = 'BASE TABLE'

read count : 10

netbeans api to read bookmark line numbers

Below code can read out bookmark line numbers for netbeans. For Java project, the bookmark line number are stored in nbproject/private/private.xml. If it is maven project, the private.xml is not exist but this code still work, there must be some place to store the bookmark info but I just don’t know. These code has a weak point, it won’t read the latest line numbers unless you close the project/netbeans.

			Project project = NetbeansUtil.getProject();
			AuxiliaryConfiguration config = ProjectUtils.getAuxiliaryConfiguration(project);
			org.w3c.dom.Element element = config.getConfigurationFragment("editor-bookmarks", "http://www.netbeans.org/ns/editor-bookmarks/2", false);
			ModuleLib.log("element=" + element);
			if (element != null) {
				NodeList list = element.getElementsByTagNameNS("http://www.netbeans.org/ns/editor-bookmarks/2", "bookmark");
				for (int x = 0; x < list.getLength(); x++) {
					org.w3c.dom.Element enEl = (org.w3c.dom.Element) list.item(x);
					String lineNo = enEl.getTextContent().trim();
					ModuleLib.log("line no=" + lineNo);
				}
			}

read count : 9

Netbeans plugins, able to compile and build != able to install in a clean netbeans

People reported my minimal plugins can’t install in their netbeans. I concluded these:

1) able to compile and build NOT EQUAL to able to install in a clean netbeans
2) able to install your plugin in your netbeans NOT EQUAL to able to install in a clean netbeans

When you meet this error : Project depends on packages not accessible at runtime

Just add the library to in pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.github.mcheung63</groupId>
        <artifactId>netbeans-minimap</artifactId>
        <version>2.8</version>
        <packaging>nbm</packaging>
        <name>Minimap</name>
        <description>Display the code minimap, programmer can overlook their code.</description>
        <developers>
                <developer>
                        <name>Peter</name>
                        <email>mcheung63@hotmail.com</email>
                        <roles>
                                <role>Founder</role>
                        </roles>
                </developer>
        </developers>
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>nbm-maven-plugin</artifactId>
                                <version>3.13</version>
                                <extensions>true</extensions>
                                <configuration>
                                        <!--<useOSGiDependencies>false</useOSGiDependencies>-->
                                        <moduleDependencies>
                                                <dependency>
                                                        <id>org.netbeans.api:org-netbeans-modules-editor-lib2</id>
                                                        <type>impl</type>
                                                </dependency>

read count : 20

old netbeans api code to get each line

g.setColor(Color.red);
		int lastLineNo = -1;
		while (hq.moveNext()) {
			AttributeSet as = hq.getAttributes();
			if (as != null) {
				try {
					lineNo = NbDocument.findLineNumber((StyledDocument) document, hq.getStartOffset());
					if (lineNo != lastLineNo) {
						lastLineNo = lineNo;
						g.drawString(String.valueOf(lineNo + 1), 0, fontHeight * (lineNo + 1) - 3);
					}
				} catch (Exception ex) {
					ModuleLib.log(CommonLib.printException(ex));
				}
			}
		}

read count : 16

get netbeans current row highlight color

		FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class);
		Coloring c = Coloring.fromAttributeSet(fcs.getFontColors(FontColorNames.CARET_ROW_COLORING));
		g.setColor(c.getBackColor());

read count : 3

Script to browse every pages of sharepoint 2013

Add-PSSnapin Microsoft.SharePoint.PowerShell
$creds = [System.Net.CredentialCache]::DefaultCredentials
$DEBUGLOG = "c:\SharePoint.log"
$SPECIFICURLs= "c:\SharePoint.URLs.txt"

function Log([string] $msg,[string] $colour)
{
    if($colour -ne "") {
        Write-Host $msg -ForegroundColor $colour
    }
    else {
        Write-Host $msg
    }
}

function Debug([string] $msg)
{
    echo $msg >> $DEBUGLOG
}

function JoinURL([string]$a,[string]$b)
{
    if($a.EndsWith('/')) { $a=$a.Substring(0,$a.length-1) }
    if($b.StartsWith('/')) { $b=$b.Substring(1) }
    return $a + '/' + $b
}

function Fetch-WebPage([string]$url,[bool]$ignoreErrors = $false)
{
    $bypassonlocal = $false
    $proxyuri = "http://" + $env:COMPUTERNAME
    $proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)

    $client = New-Object Net.WebClient
    $client.Credentials = $creds
    $client.Proxy = $proxy
    Debug "Fetching $url" 
    try {
        $pageContents = $Client.DownloadString($url) 2>&1 | Out-Null
    }
    catch {
        $msg = $error[0].ToString()
        if($ignoreErrors -eq $false) {
            Log "ERROR: $msg" "Red" 
            Debug "ERROR: $msg"
        }
    }
    $client.Dispose()
    ###Debug $pageContents
}

function ProcessWebApplication ([string]$url)
{ 
    Log "-- Root site URL: $url" "Green"
    $sitecollections = Get-SPSite $url 2>$null
    if($sitecollections -eq $null) { 
        Log "  -- No site collections found under this URL" "Cyan"
        return
    }

    $IsCA = $false
    if($sitecollections.WebApplication.IsAdministrationWebApplication) {
        Log " -- This is Central Administration" "Blue"
        $IsCA = $true
    }

    foreach($sc in $sitecollections) {
        $scUrl = JoinURL $url $sc.ServerRelativeUrl
        Log "  -- $scUrl" "Green"
        $subsites = $sc | Get-SPWeb -Limit 20
        if($subsites -eq $null) {
            Log "    -- No site collections found under this URL" "Cyan"
            continue
        }

        foreach($site in $subsites) {
            $siteUrl = JoinURL $scUrl $site.ServerRelativeUrl
            Log "    -- Fetching $siteUrl" "White"
            Fetch-WebPage $siteUrl

            # For non-Central Admin sites, try a search
            if($IsCA -eq $false) {
                # See if this site has a standard search results page
                $siteSearchUrl = JoinURL $siteUrl "/_layouts/osssearchresults.aspx?k=test"
                Log "    -- Fetching $siteSearchUrl" "White"
                Fetch-WebPage $siteSearchUrl $true

                # Bonus fetch of site search results page for Search Center sites
                $webTemplate = $site.WebTemplate
                if($webTemplate.StartsWith("SRCHCEN")) {
                    $siteSearchUrl = JoinURL $site.Url "/Pages/results.aspx?k=test"
                    Log "    -- Fetching $siteSearchUrl" "White"
                    Fetch-WebPage $siteSearchUrl
                }
            }
            $site.Dispose()
        }
    }
    Log ""
}

$zones=("Default", "Intranet", "Internet", "Custom", "Extranet")
foreach($zone in $zones) {
    Log "$zone Zone" "Yellow"
    $altURLs = Get-SPAlternateUrl -Zone $zone
    if($altURLs -eq $null) {
        Log "-- No URLs under this zone"
        continue
    }
    foreach($url in $altURLs) {
        ProcessWebApplication $url.IncomingUrl
    }
}

# Process any specific URLs
$URLFile = Get-Content $SPECIFICURLs -ErrorAction SilentlyContinue
if($URLFile -eq $null) {
    exit
}
Log ""
Log "Fetching custom URLs" "Yellow"
foreach($u in $URLFile) {
    Log "  -- Fetching $u" "White"
    Fetch-WebPage $u
}

Log "Finished."

read count : 4

Start bochs with a fixed window location

Bochs doesn’t has a parameter to specific the startup window position on screen. If you are compiling boots with SDL2. You can edit boots_source/gui/sdl2.cc, and change the first SDL_WINDOWPOS_UNDEFINED to x position and second SDL_WINDOWPOS_UNDEFINED to y position.

  window = SDL_CreateWindow(
    BOCHS_WINDOW_NAME,
    SDL_WINDOWPOS_UNDEFINED,
    SDL_WINDOWPOS_UNDEFINED,
    640,
    480,
    SDL_WINDOW_SHOWN
    );

read count : 3