MinifyFilter

package com.ofrick.filters;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.regex.*;

public class MinifyFilter implements Filter {

private Pattern regex = null;
 
 // This method is called once on server startup
 public void init(FilterConfig filterConfig) 
 {
 regex = Pattern.compile("^\\s*$\\n|\\t", Pattern.MULTILINE);
 }
 
 // This method is called for every request and needs to be thread safe.
 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
 throws java.io.IOException, javax.servlet.ServletException 
 {
 HttpServletResponse resp = (HttpServletResponse) response;
 ResponseWrapper wrapper = new ResponseWrapper(resp);
 chain.doFilter(request, wrapper);
 
 String html = wrapper.toString();

html = regex.matcher(html).replaceAll("");
 //html = multipleSpaces.matcher(html).replaceAll(" ");
 resp.setContentLength(html.getBytes().length);
 PrintWriter out = resp.getWriter();
 out.write(html);
 out.flush();
 out.close();
 }
 
 // This method is called once on server shut down
 public void destroy() 
 {
 //
 }
 
 static class ResponseWrapper extends HttpServletResponseWrapper {
 private CharArrayWriter output;

public ResponseWrapper(HttpServletResponse response) {
 super(response);
 this.output = new CharArrayWriter();
 }

public String toString() {
 return output.toString();
 }

public PrintWriter getWriter() {
 return new PrintWriter(output);
 }
 }
 
}
Posted in IT

Config snippet for JRun

Config snippet for JRun

<!–
<filter>
<filter-name>MinifyFilter</filter-name>
<filter-class>com.ofrick.filters.MinifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MinifyFilter</filter-name>
<url-pattern>*.cfm</url-pattern>
</filter-mapping>
–>

MinifyFilter.java

Posted in IT

find changed files using PowerShell

Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -ge (get-date).AddHours(-24) -and $_.FullName -like “f:\go2005\*.c*” } | ForEach-Object{$oldname = $_.Fullname; $newname = $($_.FullName).replace(‘F:’,’F:\svn\f’); New-Item -ItemType File -Path $newname -Force; Copy-Item $oldname $newname;}

Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -ge (get-date).AddMonths(-10) -and $_.FullName -like “S:\go2005\application\*.cfm” } | ForEach-Object{$oldname = $_.Fullname; $newname = $($_.FullName).replace(‘S:’,’D:\Users\Frick\Documents\sw0052sync\server\f’); New-Item -ItemType File -Path $newname -Force; Copy-Item $oldname $newname;}

Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -ge (get-date).AddMonths(-10) -and $_.FullName -like “S:\go2005\application\*.cfc” } | ForEach-Object{$oldname = $_.Fullname; $newname = $($_.FullName).replace(‘S:’,’D:\Users\Frick\Documents\sw0052sync\server\f’); New-Item -ItemType File -Path $newname -Force; Copy-Item $oldname $newname;}

Posted in IT

configure ffmpeg

./configure –disable-lua –disable-mad –disable-avcodec –disable-postproc –disable-a52 –enable-run-as-root –disable-glx

Posted in IT

Postgres for Hyperic

cd C:\Opt\pgsql
mkdir C:\Opt\pgsql\log

bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\Opt\pgsql\data

bin\pg_ctl.exe -D “C:/Opt/pgsql/data” -l “C:/Opt/pgsql/log/pgsql.log” start

bin\createuser.exe -U postgres -P

bin\createdb.exe -U postgres -e HQ

C:\Opt\server-4.6.6\bin\hq-server.bat install

Posted in IT