Sub aProc()
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("ExcelMongoDBAddin")
Set automationObject = addIn.Object
Worksheets("Sheet1").Range("A1").Value = automationObject.SayHi("One")
End Sub
VBA – Invoking an Excel addin method
C# – Underlined string to camel case.
A quite simple camel case formatter written in C# that I used to convert common table columns names into object properties names.
public class Util
{
public static string ToCamelCase(string str)
{
if (str.IndexOf('_') == -1)
return str.ToLower();
// First letter is always lower
string result = "";
str = str.ToLower();
bool toUpper = false;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == '_')
{
toUpper = true;
continue;
}
if (toUpper)
result += str[i].ToString().ToUpper();
else
result += str[i];
toUpper = false;
}
return result;
}
}
Mac Remote Desktop Connect – Attaching Console
Hi,
If you need to connect into a Windows machine using MacOSX RDC in a console mode, just use the option [/CONSOLE] after the host information at Computer textbox.
Ex:
Cya!
Groovy – How to get local ip address
Use these instructions to retrieve local address information.
[hostname]
println InetAddress.localHost.canonicalHostName
[ip address]
println InetAddress.localHost.hostAddress
Grails – MySQL broken pipe issue
Hi,
After several hours at google, I finally got a reasonable and functional solution for the MySQL broken pipe issue.
You see, my first attempted solution was to update the configuration in the [DataSource.groovy] file and to insert a Spring bean in [resource.groovy]. Something like this:
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/st?autoReconnect=true"
driverClassName = "com.mysql.jdbc.Driver"
username = "st_user"
password = "st_pass1"
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
validationQuery="SELECT 1 from dual"
testOnBorrow=true
testOnReturn=true
testWhileIdle=true
}
}
and
import grails.util.GrailsUtil
import com.mchange.v2.c3p0.ComboPooledDataSource
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
beans = {
if (GrailsUtil.environment != GrailsApplication.ENV_TEST) {
dataSource(ComboPooledDataSource) { bean ->
bean.destroyMethod = 'close'
user = CH.config.dataSource.username
password = CH.config.dataSource.password
driverClass = CH.config.dataSource.driverClassName
jdbcUrl = CH.config.dataSource.url
initialPoolSize = 10
minPoolSize = 10
maxPoolSize = 50
maxStatements = 240
maxConnectionAge = 60 * 60 * 2 // 2 hours
maxIdleTime = 60 * 60 // 1 hour
idleConnectionTestPeriod = 240
testConnectionOnCheckin = true
testConnectionOnCheckout = true
automaticTestTable = "c3p0_test"
}
}
}
Nevertheless the problem still persisted, besides the frustration I haven’t lost my faith and restarted the research again.
So, I finally got this article at: http://sacharya.com/grails-dbcp-stale-connections/
The solution is very simple, one just creates a groovy class in grails ([src/groovy] folder) within this code:
package ...your package...
import org.apache.log4j.Logger
import org.codehaus.groovy.grails.commons.ApplicationAttributes
class DataSourceUtils {
static final Logger log = Logger.getLogger(DataSourceUtils)
//
// fix for the database killing idle connections
//
// http://sacharya.com/grails-dbcp-stale-connections/
//
private static final ms = 1000 * 15 * 60
public static tune = { servletContext ->
def ctx = servletContext.getAttribute(ApplicationAttributes.APPLICATION_CONTEXT)
ctx.dataSource.with {d ->
d.setMinEvictableIdleTimeMillis(ms)
d.setTimeBetweenEvictionRunsMillis(ms)
d.setNumTestsPerEvictionRun(3)
d.setTestOnBorrow(true)
d.setTestWhileIdle(true)
d.setTestOnReturn(true)
d.setValidationQuery('select 1')
d.setMinIdle(1)
d.setMaxActive(16)
d.setInitialSize(8)
}
if (log.infoEnabled) {
log.info "Configured Datasource properties:"
ctx.dataSource.properties.findAll {k, v -> !k.contains('password') }.each {p ->
log.info " $p"
}
}
}
}
and then, update the [BootStrap.groovy] file in order to invoke the inserted class:
import ...your package... .DataSourceUtils
class BootStrap {
def init = { servletContext ->
DataSourceUtils.tune(servletContext)
}
}
and voilĂ … there you go!
For more information about this issue and it’s solution, see the Sudarshan Acharya blog site (http://sacharya.com/grails-dbcp-stale-connections/) it is very good and well explained.
ModemTunnel – Softpedia 100% free award
ModemTunnel has recently received the Softpedia 100% free award. Check it out:“100% FREE award granted by Softpedia”
Modem Tunnel
Modem Tunnel project has been unleashed.
A handy java tool for testing serial-TCP/IP communications. My first experience to open a code to the community. Click here to see it.
Sazevedo – Hello world.
A series of “Hello world” programs, and also my personal WP syntaxhighlighter plugin test. Enjoy it…
Groovy – Simpler than Java? Groovy it.
As simple as powerful. Check it out: http://groovy.codehaus.org/.
println "Hello world."
Java – Duke’s fans basic
public class Hello {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
The simplest C program
#include <stdio.h>
int main(int argc, const char **argv)
{
printf("Hello world!\r\n");
return 0;
}
For those bit fanatics, i386 assembly hello
; This was created and tested with MS [debug.com]
- a
????:0100 jmp 111
????:0102 db “Hello world.”, 0d, 0a, “$”
????:0111 mov ah, 9
????:0113 mov dx, 102
????:0116 int 21
????:0118 mov ah, 0
????:011A int 21
????:011C
-g
Obs: No highlight for assembly code, not good. Web applications ignore their wild nature.
