Friday, November 25, 2011

Kill all connections to a Microsoft SQL Server DB


-- Create the sql to kill the active database connections
declare @execSql varchar(1000), @databaseName varchar(100)
-- Set the database name for which to kill the connections
set @databaseName = 'Massive.dev'

set @execSql = ''
select  @execSql = @execSql + 'kill ' + convert(char(10), spid) + ' '
from    master.dbo.sysprocesses
where   db_name(dbid) = @databaseName
     and
     DBID <> 0
     and
     spid <> @@spid
exec(@execSql)

Source:
http://blog.tech-cats.com/2008/01/kill-all-database-connections-to-sql.html

Wednesday, October 26, 2011

Change Upload limit web.config

To change the upload limit in web.config


<!-- maxRequestLength is in KB -->
<system.web>
<httpRuntime maxRequestLength="204800" executionTimeout="99999"/>
</system.web>

If the server is iis 7 or above, also put this:
<!-- maxAllowedContentLength is in Bytes! -->
<system.webServer>
    <security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
</system.webServer>


Thursday, October 20, 2011

Thumbnails from Youtube

Para sacar ou apresentar um thumbnail (120x90) de um video do youtube

http://img.youtube.com/vi/VIDEO_ID/#.jpg

VIDEO_ID = Ao id do video de onde querem sacar o thumbnail
# = ao nº do thumbnail que o youtube gera, que vai do 1 ao 4, sendo que o youtube apresenta por default o 2. O thumbnail 0 (Zero) é a imagem em tamanho grande (480×360)

Source:
http://www.reelseo.com/youtube-thumbnail-image/

Reload AddThis Script Ajax

Quando se faz replace do html do AddThis, temos de fazer reload do script, aqui fica uma maneira de fazer (Precisa de jquery).


var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
if (window.addthis){
    window.addthis = null;
}
$.getScript( script );


Source:
http://stackoverflow.com/questions/1603835/addthis-button-will-not-work-inside-ajax-but-will-work-normally


Add facebook tab to page

Maneira simples de adicionar uma facebook tab ou app a uma página do facebook
1) Ter o id da tab ou app
2) ir até  http://www.facebook.com/apps/application.php?id=YOUR_APP_ID e fazer replace do YOUR_APP_ID com o id da tab/app
3) fazer add to my page (algures no canto infeior esquerdo)