Wednesday, February 5, 2014

Tuesday, July 9, 2013

Pidgin Google Talk using Port 443

If you're having trouble connecting to google talk from Pidgin, it might be you have your outbound tcp 5223 blocked. (you can test it by "telnet gmail.com 5223").

You can configure pidgin with the following settings then:
"The Google Talk program contains a number of fallback methods. In your GTalk account on the advanced tab, set Connect Server to "talk.google.com", Connect Port to 443, and check "Force Legacy (port 5223) SSL"."

Also, you might want to delete the pidgin "Account" and create a new one, since if you use "Modify" it might not refresh it properly.

Tuesday, March 12, 2013

Debugging with Visual Studio Development Server fails: SocketException was unhandled

System.Net.Sockets.SocketException was unhandled
  Message="Only one usage of each socket address (protocol/network address/port) is normally permitted"
  Source="System"
  ErrorCode=10048
  NativeErrorCode=10048
  StackTrace:
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.Bind(EndPoint localEP)
       at Microsoft.VisualStudio.WebHost.Server.Start()
       at Microsoft.VisualStudio.WebServer.WebServerApp.Main(String[] args)
This is probably because for some reason the last time you run debug, VSDS didn't stop running.

You can check which process is hung on the given port, and kill it with the following:

netstat -ano | findstr "5001"
Taskkill /F /PID

Tuesday, February 5, 2013

IMDB Searches

For future reference:
num_votes = min, max
sort = user_rating, desc
year = min, max
genres = sci_fi (action adventure animation biography comedy crime documentary drama family fantasy film_noir history horror music musical mystery romance sci_fi short sport thriller war western)
title_type = feature (movie)

Highest Rated Sci-Fi Feature Films Released No Later Than 2012 With At Least 20,000 Votes
http://www.imdb.com/search/title?num_votes=20000,&sort=user_rating,desc&year=,2012&genres=sci_fi&title_type=feature

Monday, February 4, 2013

localhost waits to load applet using chrome

O meu colega tinha um problema. Sempre que acedia à aplicação por localhost o browser chrome ficava pendurado (durante cerca de um minuto) nas páginas que utilizavam um componente java (applet).

Ligamos o debugger no java (control panel -> java -> advanced -> debugging -> enable tracing / enable logging / show applet life cycle exceptions) / Java Console -> Show Console)

A JVM considerava o componente como tendo expirado de validade e tentava fazer download novamente, mas como este estava por trás de autenticação integrada, e esta por alguma razão aparentemente falhava, demorava algum tempo até que a jvm se decidisse a carregar o componente com o ficheiro .jar em cache.

O workaround encontrado foi colocar a virtual folder onde o ficheiro se encontra com anonymous authentication.

Fica a pergunta se a jvm consegue fazer autenticação integrada (kerberos e/ou ntlm) e como configurar a mesma. Aparentemente pelos pedidos que eram efectuados (um dos pedidos era ao dc, e era este que ficava pendurado), seria possível realizar tal autenticação, no entanto no ambiente de qualidade as pastas referentes aos .jar também se encontram com anonymous authentication.

PS: da última vez que tive um problema semelhante também coloquei excepções no web server para permitir anonymous ao servir ficheiros com a extensão .jar, no entanto esta solução pode não ser aceitável onde os ficheiros .jar contenham regras de negócio.

Sunday, May 6, 2012

UDP UPnP Ports Opening from SVCHOST.EXE NETSVCS (range 50k - 60k)

So, i noticed that one of my computers kept opening a UPnP rule on my firewall(if i kept UPnP on), but the other didn't. Searching with netstat -ano gave me the PID, which was svchost.exe netsvcs. Now, this doesn't say much since a lot of services run on svchost. Searching with the port number, or the services wouldn't give much results as the port was dynamic. After some more google persistance i found out the command to list each service that was running in each PID and the name of the services inside. tasklist /svc
Browser, EapHost, gpsvc, IKEEXT, iphlpsvc, LanmanServer, ProfSvc, Schedule, SENS, ShellHWDetection, Themes, Winmgmt, wuauserv
So now i got something similar to this, and by trial and error i eventually found out that, if i stoped IPHLPSVC, i would stop listening to the port. In the end, when i searched the net with IPHLPSVC i found someone with the same questions i had and with some precious tip that might save me time next time:
http://forums.comodo.com/firewall-help-cis/svchostexe-port-57398-whats-going-on-here-t72975.0.html
http://processhacker.sourceforge.net/
This service is somehow responsible by the horrible teredo and other tunnels that appear in your ipconfig list since they invented IPv6. Somehow i suspected when i checked IKEEXT that this would have to do something to do with IPv6. But why did i have this open in one computer and not in the other?
Anyway, just to make sure, i reenabled the service, but nothing happened nevertheless. The UDP port will only get open when you actually attempt to do a IPv6 connection. It seems the UDP port will try to emulate IPv6 connections even if you're using IPv4. Something to try to understand in the future. For now i am happy that I didn't had a worm somewhere...
PS: If you want you can set it off by using netsh interface teredo / set state disabled (set state default - to reenable)

Wednesday, March 7, 2012

github first time

GitHub is free for open-source projects, so let's try to make the excels / forms i've been using into a web project using VS2010.
Since i'm fairly new with VS2010 i went with the usual Web C# project. Installed Git Extensions and followed:

http://help.github.com/set-your-user-name-email-and-github-token/
http://help.github.com/create-a-repo/

Now i created a VS Project inside that directory and when i tried to push i got an error. "No supported authentication methods available"

So, it ends up you need to create a ppk file and configure putty to use it (if you installed github with putty = the default option).

Go ahead to Remotes -> PuTTY -> Generate or import key. Now, go to Conversions -> Import key. Browse to the .ssh folder, and find 'id_rsa' (it was named exactly that here, WITHOUT an extension). Select it, and press open. Enter the password for your key (this is the key that Git uses to communicate to the GitHub server, as it appears). Then, select Save Private Key, and save it somewhere (I did in the .ssh folder)

Now you have the option select the ppk file when the "No supported authentication methods available" arises, and it should work. (of course, you need the private key, silly!).

http://stackoverflow.com/questions/6138493/unable-to-push-to-repository-using-git-extensions

Wednesday, July 20, 2011

A sério, não custava muito pois não?

sc delete bblearn-collab
sc delete bblearn-exec
sc delete bblearn-tomcat
rd /s blackboard
C:\Windows\SysWOW64\inetsrv\appcmd delete site "BBLEARN"

DECLARE @jobId binary(16)
SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'aa_update_BBLEARN')
IF (@jobId IS NOT NULL)
BEGIN
EXEC msdb.dbo.sp_delete_job @jobId
END
SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'Fill missing Adaptive tool BBLEARN')
IF (@jobId IS NOT NULL)
BEGIN
EXEC msdb.dbo.sp_delete_job @jobId
END
DROP DATABASE BBLEARN;
DROP DATABASE BBLEARN_admin;
DROP DATABASE BBLEARN_cms;
DROP DATABASE BBLEARN_cms_doc;
DROP DATABASE BBLEARN_stats;
DROP LOGIN BBLEARN;
DROP LOGIN BBLEARN_admin;
DROP LOGIN BBLEARN_cms;
DROP LOGIN BBLEARN_report;
DROP LOGIN BBLEARN_stats;

Thursday, February 10, 2011

Sharepoint e forçar SSL

Quando se quer forçar SSL no sharepoint há que ter em conta o tipo de autenticação que temos implementada.


Se o Sharepoint se encontrar em Windows autentication, podemos aceder à consola de administração do IIS e dentro do tab de directory security seleccionar "require secure channel" ssl. É possível costumizar a resposta de erro 403.4 para redireccionar o cliente a fazer o pedido por https.
http://www.winserverkb.com/Uwe/Forum.aspx/windows-server-sbs/27476/How-to-force-SSL-on-a-SharePoint-site

Caso desejem colocar o sharepoint em forms authentication encontrei este link que mostra como colocar apenas partes do Sharepoint sob SSL (i.e. a página de login).
http://www.sharepointconfig.com/2010/03/enforcing-the-correct-protocol-for-partially-ssl-secured-sharepoint-sites/

Tuesday, November 23, 2010

Como actualizar o Windows/Linux por trás de um proxy com NTLM Authentication

Podem usar as actualizações do Windows/Linux por trás de um proxy com NTLM Authentication, usando um programinha chamado ntlmaps que corre em Python. Este programinha cria um segundo proxy local que é capaz de fazer autenticação no proxy que exige authenticação NTLM. A password pode ser introduzida de forma interactiva.

1 - Instalar o Python e ntlmaps.
2 - Configurar ntlmaps.
3 - Configurar o yum ou o windows para usar o proxy ntlmaps em vez do proxy que está configurado.

Passo 3:
Windows:
netsh winhttp set proxy proxy-server="http=localhost:5865;https=localhost:5865" bypass-list="*.foo.com"
Linux:
export http_proxy=http://localhost:5865
ou actualizar/adicionar a seguinte linha ao yum.conf
proxy=http://localhost:5865

Se com localhost nao estiver a funcionar usem o nome completo da máquina.

http://www.howtoforge.com/how-to-configure-isa-proxy-auth-setting-for-yum
http://technet.microsoft.com/en-us/library/cc731131(WS.10).aspx

Thursday, July 8, 2010

Passing a PARAMETER to a IN CLAUSE

Trying to pass a parameter to a "in clause" can be troublesome, because what you really want to do is to pass an array of an indefinite number of parameters and not a single parameter.

There are 2 solutions for this. Either you pass a table-value type, or you use a function to convert the nvarchar to a table.
Here is how such function might look like:
CREATE FUNCTION iter$simple_intlist_to_tbl (@list nvarchar(MAX))
RETURNS @tbl TABLE (number int NOT NULL) AS
BEGIN
DECLARE @pos int,
@nextpos int,
@valuelen int

SELECT @pos = 0, @nextpos = 1

WHILE @nextpos > 0
BEGIN
SELECT @nextpos = charindex(',', @list, @pos + 1)
SELECT @valuelen = CASE WHEN @nextpos > 0
THEN @nextpos
ELSE len(@list) + 1
END - @pos - 1
INSERT @tbl (number)
VALUES (convert(int, substring(@list, @pos + 1, @valuelen)))
SELECT @pos = @nextpos
END
RETURN
END


For more information about this error and credits for the code here check out:
http://www.sommarskog.se/arrays-in-sql.html

Wednesday, June 23, 2010

apache apxs perl "^M: bad interpreter: No such file or directory"

I am trying to compile or make something and get this stupid error that perl is not there, but i have checked and both perl and apxs file are there and have the right permissions.

Solution:
Your apxs file has come from a windows machine and is in dos format, therefore perl is unable to properly understand the commands you're sending it.

run:
dos2unix apxs

and you should be good to go.

How to compile a 32bit dynamic library on a 64bit linux

You can use -m32 or -m64 flag to tell the gcc compiler to compile in 32 or 64 bit.

Now, the trick is that configure and make will accept this flags, if you insert them in the CC variable like this:

./configure CC="gcc -m32"

or when with make

make CC="gcc -m32"

Hope this saves you some frustration i had gone through trying to compile it by hand.

Monday, April 12, 2010

Alps Pad da Dell ao editar texto faz saltar de linha

Existe um problema com os pad da Dell. Quando estão a editar texto se por acaso tocarem no "stick" ou apoiarem a mão no "pad" podem enviar um click no mouse o que vos vai fazer saltar de linha. Este processo pode não só ser bastante frustrante como introduzir erros no código/texto sem que nos apercebamos.

Uma maneira de resolver o assunto é fazer download dos últimos drivers alps no site da dell. Um icon será instalado no ambiente de trabalho. A partir daí podemos aceder à configuração e seleccionar "Desative o Touch Pad/Stick quando houver um dispositivo apontador USB". Se estiverem a editar texto sem rato podem sempre reduzir a sensibilidade ou desactivar o stick para que a frustração não volte a atacar o vosso dia.

Friday, April 9, 2010

Como resolver utilizadores orfãos no Sql Server

Depois de fazer restore a uma base de dados de outra instalação os utilizadores podem ficar orfãos (o nome é o mesmo mas o SID é diferente de instalação para instalação).

Eis como resolver o problema:

-- Quais os utilizadores orfãos?
sp_change_users_login @Action='Report';

-- O 'utilizador' username da base de dados é o utilizador 'username' no sql server:
sp_change_users_login @Action='update_one', @UserNamePattern='username',
@LoginName='username';

Wednesday, March 31, 2010

DTSX - Connection Credentials Management


When you create a DTSX the "Security/Protection Level" property will be set by default to "EncryptSensitiveWithUserKey". Why should you want to know this?

Well, this property means it will encrypt sensitive information with your user credentials. Another thing that is not so explicit about this setting is that all sensitive information will be bound to your machine. Now, this might not be a good idea since most of the time you will not develop in production environment.

In practical terms this means whenever you try to edit or run this dtsx in another machine errors will be raised when you try to read the credentials for the connection to the database.



Error loading mydtsx.dtsx: Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information.

Validation error. Data Flow mydtsx: Connection1 [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Connection1" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.

One of the ways to overcome this is to change the property to EncryptSensitiveWithPassword. This way you will be asked to set a password, that will be required to decrypt sensitive information when you run/edit it next time.

e.g. DTEXEC /FILE "C:\MyDTSX.dtsx" /MAXCONCURRENT "-1" /CHECKPOINTING OFF /REPORTING EW /DE MyPassword

TIP: You can set this commad line to run in the scheduled tasks. To set it to run as system account use: NT Authority\System

Friday, March 26, 2010

"Application popup: : "

"Application popup: : " Event ID: 26 can be anything. Basically means a nameless application has thrown a nameless error. After a while the worker application pool process w3wp.exe would throw other events on systems tab like:

"A process serving application pool 'AppPool11' terminated unexpectedly. The process id was '1932'. The process exit code was '0x1'."

"Application pool 'AppPool11' is being automatically disabled due to a series of failures in the process(es) serving that application pool."

"A process serving application pool 'AppPool11' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was '3424'. The data field contains the error number. "

Just for the record, the server was a x64 windows server running among other things .net 1.1 web application.

To cut the story short, we were able to isolate the code that was throwing this error (a third party opensource dll called pdfsharp). The dll would work great as long it was saving/creating pdf, but as soon you tried the .Open command, either passing "stream" or "string to path" when called, the title blank application popup error was thrown only once on the system event viewer (until a reset on the worker was thrown by reseting the iis or killing the process) TIP: You can check the threads on a process with the sysinternals process explorer. In 32bit everything works fine (of course).

Interesting was that the request wouldn't catch that an error occured, meaning the thread would get stuck in the w3wp.exe worker. After a few hung threads (10?) the application pool would stop responding to requests and had to be terminated by the iis as shown.

Thank god we are working with 8 years old technologies, or our life would be pretty boring... not!