Friday, December 12, 2014

calling .net dll from asp classic

tested on visual studio pro 2013 and windows 8 / 2012

First, create a new vb / c# project com class component.
Then go to project properties,
Application tab > assembly information > Check Make Assembly com visible
Compile tab
Check Register for com interop
(makesure to sign your app, otherwise you cant register with gac)
Signing tab > Sign the assembly > Create a password

Okay, now to solution explorer on the right side,
Right click on solution and add item
Common items > Code > Com Class

Declare your class with method required,
Remember this class will be visible from outside.

When done building your project,
Go to Build > Build [your projectname]

goto start, find for visual studio tools
run VS2013 x64 Native Tools Command Prompt
(please take note that this is x64 environment).
So we need to run regasm and gacutil from x64 tools, not the default 32bits

Then cd \yourprojectpath\yourclass\bin\Debug\
regasm yourfile.dll
(need to sign assembly)

gacutil -i yourfile.dll

Then you may check if your registry is registered by calling
HKLocal Machine > Software > Classes > YourProjectname.YourObject

okay, then restart iis. and test your dll in asp:
dim foo
set foo = Server.CreateObject("YourProjectname.YourObject")

dim pass
pass = "abA2356!"

if foo.ValidatePassword(pass) then
Response.Write "all ok!"
    response.Write "not ok!"
end if

other references:

Thursday, October 23, 2014

fixing poodle vulnerabilities on cpanel services

This guide will help to disable ssl2 and ssl3 support.


#SSLProtocol ALL -SSLv2 -SSLv3

restart service
/etc/init.d/cpanel restart

openssl s_client -connect -ssl3

should get error
44604:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:/SourceCache/OpenSSL098/OpenSSL098-52/src/ssl/s3_pkt.c:1125:SSL alert number 40
44604:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:/SourceCache/OpenSSL098/OpenSSL098-52/src/ssl/s3_pkt.c:546:

openssl s_client -connect -tls1

do not add -SSLv3 to SSL_cipher_list as it will disable tls as well.

Tuesday, October 21, 2014

laravel saving child model

Took me hours to finally figure this out.

When calling child has_many, calling method seems to return the association / querybuilder,
but calling attribute seems to return the collection.

so save the child record,


to get list of collection of childs, calling:

foreach($object->childs as $child)

Friday, September 12, 2014

overriding spree javascripts

to overwrite spree javascripts, such as,

first , enable assets path in config/application.rb

config.assets.paths << "#{Rails.root}/assets"

Next, copy the assets file to the same directory path as the assets on spree.
spree / core / app / assets / javascripts /

Then run this on server, if its in production mode:
bundle exec rake tmp:clear

then restart the server,
thin restart, or what ever server you are using. you may stop and start.

if you need to add more file, you may edit:
vendor/assets/javascripts/spree/frontend (or backend) / all.js

hope it helps :)

Sunday, August 24, 2014

Marionette CompositeView appendHTML changed to attachHtml

another latest marionette change

Marionette compositeView changed itemView to childView!

it was changed, and nobody was notified,
not that i could google until i found its not working...

terrible community update

Thursday, July 24, 2014

undefined method ... path due to polymorphic_url

i came across this non meaningful error,
as it turn out to be a mis named params

example: mispelled params[:nam] for params[:name]

Friday, July 18, 2014

ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds)

it turn out there could be 2 reasons,

1. rails connection pool have reached and there might be zombie connection
2. mysql max_connections / max_user_connections may have reached

in most cases, its the first possibility.
ensure that you have set the connection pool to a much higher value,
to handle enough concurrent users at the same time

  adapter: mysql2
  pool: 100

2nd issue is due to zombie connection which may lead filling up pool with undead connections.
add a config/initializers/db_connections.rb
with these code:
Rails.application.config.after_initialize do

  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[Rails.env] ||
    config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
    #config['pool']              = ENV['DB_POOL']      || ENV['MAX_THREADS'] || 5
    puts "pool size: "+config['pool'].to_s
these should hopefully handle undead issue for db connections.

another fix is possible to fix network connection bug when writing to a disconnected connection.
------------------ data
#workaround hang stream due to client dc halfway:
sleep 0.0001

to check number of active connections for a database,
run rails dbconsole# (makesure you have set RAILS_ENV to the correct environment)


thanks to these articles:

Wednesday, June 25, 2014

Circular dependency detected while autoloading constant

When face upon this issue,
its caused by naming controller or calling model name incorrectly.

possible issue are naming are case sensitive.
class Oi


But calling
OI.find #this lead to circular dependency error

Tuesday, May 20, 2014

Spree new.before?

Spree has nifty callbacks for controller,
but what about new.before?

new_action.before :method_name

Monday, March 24, 2014

[atpvbaen.xls].WorkDay replaced

[atpvbaen.xls].WorkDay has been replaced by Application.WorksheetFunction.WorkDay in office 2010

Wednesday, March 19, 2014

work around for FB.XFBML.parse

For what ever reason due to reason update or facebook changes,
the god damn FB.XFBML.parse stop working...

found a work around:
if you are using fbml, eg:
[div id="mylike" class="fb-like" data-href=""][/div];

#reload all fb like iframe:
function reloadFB() {
 var boxes = jQuery(".fb-like iframe");
 for(var c=0; c < boxes.length; c++) {
  var box = boxes[c];
  box.src=  box.src;