Un ottimo tool per creare file robot.txt personalizzati secondo le esigenze e con un ottima spiegazione:
http://www.mcanerin.com/EN/search-engine/robots-txt.asp
mercoledì 6 marzo 2013
venerdì 22 febbraio 2013
Redirect Dominio con Enom e Blogger
Se avete comprato un dominio direttamente dal pannello di amministrazione di blogger e volete cambiarlo impostando anche un redirect dal vecchio al nuovo, ecco in breve la procedura.
Intanto comprate un nuovo dominio. Io ho usato http://www.enom.com/ che è lo stesso che utilizza google.
Nel pannello di controllo del dominio, alla voce host records, ho impostato i campi così:
www – CNAME(Alias) – ghs.google.com
@ - A (Address) – 216.239.32.21
@ - A (Address) – 216.239.34.21
@ - A (Address) – 216.239.36.21
@ - A (Address) – 216.239.38.21
* - A (Address) – 216.239.32.21
Poi ho aggiunto un campo che ho trovato nel pannello di amministrazione di blogger, sotto impostazioni, quando inserisco il nome del mio nuovo dominio. Se cambio il nome dal vecchio al nuovo, mi dice che non riesce a trovare una voce e vi indica come deve chiamarsi e che valore deve contenere. Sono caratteri senza alcun senso, come se fosse un id univoco.
Una volta impostato questo, il nuovo dominio è già funzionante.
Manca il redirect.
Per accedere al corretto pannello di controllo del dominio registrato tramite google, bisogna accedere a Google Apps For Business, http://www.google.com/intl/it/enterprise/apps/business/, dove ci sono alcune impostazioni del dominio. Da qui accedere alle impostazioni del dominio del sito in cui è realmente stato registrato. Generalmente enom, ma credo che google ne utilizzi anche un altro. Credo che si possa anche accedere direttamente ad enom da qui http://manage.exabytes.com/ .
Qui troverete una pagina con gli host records. Semplicemente vanno aggiunti i record @ e www con l’indirizzo del nuovo sito e come tipo URL REDIRECT.
Ad esempio:
@ - http://www.nuovodominio.it – URLREDIRECT
www - http://www.nuovodominio.it - URLREDIRECT
Io non potevo cancellare quelli impostati da google, che sono praticamente gli stessi di quelli scritti sopra. In questo caso ho rinominato gli HostName esistenti chiamandoli con lettere alfabetiche a caso e, importante, ho impostato i RecvordType a TEXT.
Fine.
martedì 5 febbraio 2013
XS Duration XML e String di Visual Studio
Un giorno ti capiterà SICURAMENTE di dover fare una chiamata a un webService passando anche un parametro che l'XML si aspetta sia di tipo DURATION. Tu sai dalla documentazione che per duration si intendono semplicemente dei giorni e Visual Studio ti dice che si aspetta una stringa. Cosa fai?
SEMPLICEMENTE, generi un nuovo TimeSpan con il numero dei giorni, new TimeSpan(2,0,0,0) e lo converti in stringa tramite XMLConvert.ToString().
Lui crea in questo caso la stringa P2D.
E tutto funziona.
FACILE, no?
Ecco l'esempio:
TimeSpan timeSpan = new TimeSpan(2,0,0,0);
string Duration = XmlConvert.ToString(timeSpan);
| XML Schema (XSD) type | .NET Framework type |
|---|---|
| anyURI | System.Uri |
| base64Binary | System.Byte[] |
| Boolean | System.Boolean |
| Byte | System.SByte |
| Date | System.DateTime |
| dateTime | System.DateTime |
| decimal | System.Decimal |
| Double | System.Double |
| duration | System.TimeSpan |
| ENTITIES | System.String[] |
| ENTITY | System.String |
| Float | System.Single |
| gDay | System.DateTime |
| gMonthDay | System.DateTime |
| gYear | System.DateTime |
| gYearMonth | System.DateTime |
| hexBinary | System.Byte[] |
| ID | System.String |
| IDREF | System.String |
| IDREFS | System.String[] |
| int | System.Int32 |
| integer | System.Decimal |
| language | System.String |
| long | System.Int64 |
| month | System.DateTime |
| Name | System.String |
| NCName | System.String |
| negativeInteger | System.Decimal |
| NMTOKEN | System.String |
| NMTOKENS | System.String[] |
| nonNegativeInteger | System.Decimal |
| nonPositiveInteger | System.Decimal |
| normalizedString | System.String |
| NOTATION | System.String |
| positiveInteger | System.Decimal |
| QName | System.Xml.XmlQualifiedName |
| short | System.Int16 |
| string | System.String |
| time | System.DateTime |
| timePeriod | System.DateTime |
| token | System.String |
| unsignedByte | System.Byte |
| unsignedInt | System.UInt32 |
| unsignedLong | System.UInt64 |
| unsignedShort | System.UInt16 |
venerdì 18 gennaio 2013
Visualizzare i Processi che Utilizzano una porta
Run the following command from a command prompt to find the PID of the process which is using TCP port 80 and/or 443.
netstat -aon | find ":80"
netstat -aon | find ":443"
You will see an output similar to the following. Remember the actual PID will vary from case to case.
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3604
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 3320
Now using Task Manager you can easily find out to which process the above PID belongs and take appropriate action.
In order to get to know, or view, retrieve and identify the process ID or PID of the processes running in Windows operating system, users or administrators can make use of Task Manager. However, Task Manager does not display PID information by default. To display the PID value in Task Manager, go toProcesses tab, click on View menu, then click on Select Columns…. In the “Select Columns” or “Select Process Page Columns” dialog, tick and check the checkbox for PID (Process Identifier), and click OK.
netstat -aon | find ":80"
netstat -aon | find ":443"
You will see an output similar to the following. Remember the actual PID will vary from case to case.
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3604
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 3320
Now using Task Manager you can easily find out to which process the above PID belongs and take appropriate action.
In order to get to know, or view, retrieve and identify the process ID or PID of the processes running in Windows operating system, users or administrators can make use of Task Manager. However, Task Manager does not display PID information by default. To display the PID value in Task Manager, go toProcesses tab, click on View menu, then click on Select Columns…. In the “Select Columns” or “Select Process Page Columns” dialog, tick and check the checkbox for PID (Process Identifier), and click OK.
martedì 27 novembre 2012
Insert Japanese Characters in SQL Server
To insert Japanese Characters or when dealing with Unicode string constants in SQL Server, you must precede all Unicode strings with a capital letter N, and you need to use nvarchar for the colums.
If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.
Use this meta in the webpage as well:
An example of query will be:
If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.
Use this meta in the webpage as well:
An example of query will be:
INSERT INTO dbo.sample VALUES ( '12345' ,N'を許可し );
martedì 30 ottobre 2012
Registrazione al sito tramite Google Login
Ottenere informazioni da Google per la registrazione degli utenti al nostro sito è una pratica abbastanza facile. Io personalmente ci ho sbattuto la testa per un giorno, perché cercando su internet ho trovato migliaia di versioni, una più complicata dell'altra. Qualcuno aveva persino consigliato di scaricare l'intera libreria SDK di google per C#, da ben 27 mega! Altri rispondevano con cose quasi surreali, o con pezzi di codice palesemente errati.
Ovviamente quello che leggerete qui è una sintesi, e va adattata alle vostre esigenze. Vi riporterò i link della documentazione ufficiale che in ogni caso vi conviene leggere.
Il succo del succo è questo: registrate una nuova applicazione nella Google Api Console, inserendo un vostro dominio (anche localhost per provare) e il percorso della pagina che riceverà i dati da Google.
Creare un link in una vostra pagina con un indirizzo particolare che scriverò sotto.
Tramite questo link google chiederà le autorizzazioni all'utente e vi ritornerà (alla pagina che avete impostato) un token.
Prendete quindi questo token e tramite una chiamata al webservice di Google otterrete le informazioni dell'utente.
Prima di tutto dovete registrare una nuova applicazione nelle Google Api Console, e cominciare a leggere i link della documentazione ufficiale:
<%--
First of ALL: Register an Application on Google Api Console
GOOGLE API CONSOLE:
DESCRIZIONE IN GENERALE:
DESCRIZIONE PER IL LOGIN:
--%>
Poi è la volta del link.
<%-- Qui alcune informazioni sui parametri da passare che comporranno il link
First: Click to connect to google
response_type = Determines if the Google Authorization Server returns an authorization code, or an opaque access token.
client_id = Indicates the client that is making the request. The value passed in this parameter must exactly match the value shown in the APIs Console.
redirect_uri = Determines where the response is sent. The value of this parameter must exactly match one of the values registered in the APIs Console (including the http or https schemes, case, and trailing '/').
scope = Indicates the Google API access your application is requesting. The values passed in this parameter inform the consent page shown to the user. There is an inverse relationship between the number of permissions requested and the likelihood of obtaining user consent.
state = This optional parameter indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. Possible uses include redirecting the user to the correct resource in your site, nonces, and cross-site-request-forgery mitigations.
--%>
Il link sarà del tipo:
Login con Google
Leggete bene a cosa servono tutti questi parametri e notate che lo scope deve essere decodificato correttamente.
userinfo.email vi permette di ricevere le informazioni sull'email oltre a quelle del profilo ottenute da userinfo.profile.
In questo caso il link è sulla pagina LoginGoogle.aspx e il redirect è sulla stessa pagina. Quindi Google invierà il token in querystring alla stessa pagina.
Poi è la volta della chiamata al webservice. Magari sarà in un'altra pagina, in ogni caso deve essere solo un esempio da adattare. Mi sono aiutato con JQuery e ho scritto nei commenti tutti i valori che ritorna google. Utilizzate i valori che vi ritorna per le vostre esigenze.
Il token è preso dalla querystring con la funzione che c'è all'inizio dello script e non con Request.Querystring in JS come scrivono in molti!
<%--
Second: Click to get the Token from querystring and connect again to google to request user information.
--%>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
// First, parse the query string (In Js does not exists Request.QueryString!)
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
//All that returns Google
var token = params['access_token']; //access token to your application if the user grants your application the permissions it requested
var state = params['state']; //If the state parameter was included in the request, then it is also included in the response.
var token_type = params['token_type']; // kind of token that is being returned
var expires_in = params['expires_in']; //lifetime of the token in seconds
//Call Google Webservice
$(document).ready(function () {
$.ajax({
type: "GET",
url: "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token,
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
//async: false,
success: function (result) {
var id = result.id; //The value of this field is an immutable identifier for the logged-in user, and may be used when creating and managing user sessions in your application. This identifier is the same regardless of the client_id. This provides the ability to correlate profile information across multiple applications in the same organization. The value of this field is the same as the value of the userid field returned by the TokenInfo endpoint.
var email = result.email; //The email address of the logged in user
var verified_email = result.verified_email; //A flag that indicates whether or not Google has been able to verify the email address.
var name = result.name; //The full name of the logged in user
var given_name = result.given_name; //The first name of the logged in user
var family_name = result.family_name; //The last name of the logged in user
var picture = result.picture; //The URL to the user's profile picture. If the user has no public profile, this field is not included.
var locale = result.locale; //The user's registered locale. If the user has no public profile, this field is not included.
var timezone = result.timezone; //The default timezone of the logged in user
var gender = result.gender; //The gender of the logged in user (other|female|male)
alert(gender);
//$('#txtCheckUsername').val(result.d);
},
error: function (result) {
alert('Error...');
}
});
});
</script>
<script language="javascript" type="text/javascript">
// First, parse the query string (In Js does not exists Request.QueryString!)
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
//All that returns Google
var token = params['access_token']; //access token to your application if the user grants your application the permissions it requested
var state = params['state']; //If the state parameter was included in the request, then it is also included in the response.
var token_type = params['token_type']; // kind of token that is being returned
var expires_in = params['expires_in']; //lifetime of the token in seconds
//Call Google Webservice
$(document).ready(function () {
$.ajax({
type: "GET",
url: "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token,
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
//async: false,
success: function (result) {
var id = result.id; //The value of this field is an immutable identifier for the logged-in user, and may be used when creating and managing user sessions in your application. This identifier is the same regardless of the client_id. This provides the ability to correlate profile information across multiple applications in the same organization. The value of this field is the same as the value of the userid field returned by the TokenInfo endpoint.
var email = result.email; //The email address of the logged in user
var verified_email = result.verified_email; //A flag that indicates whether or not Google has been able to verify the email address.
var name = result.name; //The full name of the logged in user
var given_name = result.given_name; //The first name of the logged in user
var family_name = result.family_name; //The last name of the logged in user
var picture = result.picture; //The URL to the user's profile picture. If the user has no public profile, this field is not included.
var locale = result.locale; //The user's registered locale. If the user has no public profile, this field is not included.
var timezone = result.timezone; //The default timezone of the logged in user
var gender = result.gender; //The gender of the logged in user (other|female|male)
alert(gender);
//$('#txtCheckUsername').val(result.d);
},
error: function (result) {
alert('Error...');
}
});
});
</script>
// First, parse the query string (In Js does not exists Request.QueryString!)
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
//All that returns Google
var token = params['access_token']; //access token to your application if the user grants your application the permissions it requested
var state = params['state']; //If the state parameter was included in the request, then it is also included in the response.
var token_type = params['token_type']; // kind of token that is being returned
var expires_in = params['expires_in']; //lifetime of the token in seconds
//Call Google Webservice
$(document).ready(function () {
$.ajax({
type: "GET",
url: "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token,
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
//async: false,
success: function (result) {
var id = result.id; //The value of this field is an immutable identifier for the logged-in user, and may be used when creating and managing user sessions in your application. This identifier is the same regardless of the client_id. This provides the ability to correlate profile information across multiple applications in the same organization. The value of this field is the same as the value of the userid field returned by the TokenInfo endpoint.
var email = result.email; //The email address of the logged in user
var verified_email = result.verified_email; //A flag that indicates whether or not Google has been able to verify the email address.
var name = result.name; //The full name of the logged in user
var given_name = result.given_name; //The first name of the logged in user
var family_name = result.family_name; //The last name of the logged in user
var picture = result.picture; //The URL to the user's profile picture. If the user has no public profile, this field is not included.
var locale = result.locale; //The user's registered locale. If the user has no public profile, this field is not included.
var timezone = result.timezone; //The default timezone of the logged in user
var gender = result.gender; //The gender of the logged in user (other|female|male)
//alert(gender);
},
error: function (result) {
alert('Error...');
}
});
});
martedì 16 ottobre 2012
Migration From MySql to Sql Server
Ecco la procedura per la migrazione da MySql a SqlServer.
Scaricare Microsoft SQL Server Migration Assistant (SSMA) for MySQL (SSMA is a tool to automate migration from MySQL database to SQL Server)
Una volta scaricato, installato e avviato, la procedura è facilissima:
Collegare il DB MySql - Tasto in alto nella barra degli strumenti "Connect To MySql".
Collegare SqlServer - Tasto in alto nella barra degli strumenti "Connect To SqlServer".
Assicuratevi di avere configurato un utente con privilegi di amministrazione sia su MySql che su SqlServer.
Avremo quindi due schermate: una in alto con i nostri db in MySql ed una in basso con quelli di SqlServer.
In alto, fate tasto destro sul db da migrare e cliccate su Convert Schema. Questo crea il db e le tabelle in SqlServer.
In basso, fate click col tasto destro sul nuovo db creato automaticamente e cliccate su Synchronize With Database. Questo effettuerà la vera connessione col db.
Infine cliccate su Migrate Data, in alto nella balla degli strumenti.
Iscriviti a:
Commenti (Atom)



