Saturday 8 September 2012

PHP Script How to split domain from e-mail


function getDomainFromEmail($email)
{
// Get the data after the @ sign
$domain = substr(strrchr($email, "@"), 1);

return $domain;
}

// Example

$email = 'the_username_here@yahoo.com';

$domain = getDomainFromEmail($email);

echo $domain; // yahoo.com
?>

How to add a UPN suffix with VBScript VBS


'----------Script configuration

Const ADS_PROPERTY_APPEND=3
strNewSuffix="test.com"
strDomain="domain.com"    'This must be the domain you're working with. If it is single domain - this is its name here

'----------End Script configuration

set objRootDSE =GetObject("LDAP://"&strDomain & "/RootDSE")
set objPartitions=GetObject("LDAP://cn=Partitions,"& _
                              objRootDSE.Get("ConfigurationNamingContext"))
objPartitions.PutEx ADS_PROPERTY_APPEND, "uPNSuffixes", Array(strNewSuffix)
objPartitions.SetInfo

How to setup NTP time sync in Windows Server 2008


The good news is: When configured correctly, you can use the Windows Time (W32Time) service as an SNTP/NTP server for both windows and non-windows SNTP/NTP clients.
Here's how to do it:
  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry entry:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\
  3. In the right pane, right-click AnnounceFlags, and then click Modify.
  4. In the Edit DWORD Value dialog box, under Value data, type 5, and then click OK.
  5. Enable NTPServer.
    1. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
                                                      Services\W32Time\TimeProviders\NtpServer\
    2. In the right pane, right-click Enabled, and then click Modify.
    3. In the Edit DWORD Value dialog box, type 1 under Value data, and then click OK.
  6. Exit Registry Editor.
  7. At the command prompt, type the following command to restart the Windows Time service, and then press ENTER:net stop w32time && net start w32time
This should get you setup with minimal registry hack impact.
Tips
  • Make sure W32Time is set to Automatic startup mode.
  • Make sure UDP 123 is allowed through your firewall.
  • Use this InternetTime program to help you debug connectivity to your SNTP/NTP server.

Windows 7 RDP how to hide remotely logged on users


  • Once you are logged into one of these editions of Windows 7, type "secpol.msc" into the start menu's search field and click on the first result, or type it into the Run dialog and hit Enter.
    Launch the Local Security Policy snap-in editor in Windows 7
  • This launches the "Local Security Policy" editor / snap-in; double-click on "Local Policies" to expand it, and select "Security Options". Then, scroll down until you find the entry labeled "Interactive logon: Do not display last user name", and double-click on it.

    This is a simple dialog which offers only two settings, "Disabled" being checked by default. Select "Enabled", and click on the "OK" button to apply the new setting (takes effect immediately).
    Hide usernames on Windows 7 logon screen
  • You can now test how the modified Windows 7 logon screen looks: hold down the Windows logo key and press "L" (as in Lock). Then, click on the "Switch user" button to see all other users, and all you'll see are two blank text fields for username and password, respectively.

Hide usernames on logon screen using the registry

If you have Windows 7 Home Premium / Basic or Windows 7 starter, here's how to enable the same setting using the registry. Type "regedit" in the start menu's search field, and click on the first result. Once the registry editor has opened, go to the following node (double-click on each to expand it).

HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > Policies > System
Edit the "DontDisplayLastUserName" DWORD (create it if needed), and change its value to "1" to enable the feature, or "0" to disable it. The new setting also takes effect right away.
Disable usernames on Windows 7 welcome screen through registry

Windows 7 where is All users Dekstop and Start Menu folder


All users desktop:
C:\Users\Public\Desktop\
All users start menu:
C:\ProgramData\Microsoft\Windows\Start Menu\

How to install DropBox for all users in Windows 7 64-bit




when you install DropBox using “run as administrator” the program gets installed to the administrator profile and wouldn’t be available for other users on the system.

Follow below steps to make the application available for all users on the system:

  1. Copy the DropBox install folder “C:\Users\Administrator\AppData\LocalLow\Dropbox” to “C:\Program Files (x86)\DropBox” folder
  2. Create a shortcut in “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\DropBox” folder to "C:\Program Files (x86)\DropBox\bin\Dropbox.exe"
  3. Copy the Shortcut to C:\Users\Public\Desktop folder as well to make it available to all users on their desktop
  4. when users launch the app they will be prompted to reconfigure app where they can specify their custom dropbox folder location

How to import users into Active Directory AD from CSV


In Windows Server 2008 Launch Powershell

import-module activedirectory

Check the modules installed:
Get-Module -ListAvailable


import-csv names.csv | new-aduser
import-csv -delim ";" -path "C:\import.csv" 



$users = import-csv -delim ";" -path "C:\import.csv" 
foreach($user in $users)
{
   $pass = $user.Password
   $nom = $user.SamAccountName
   $prenom = $user.SamAccountName
   $displayname = $nom
   $login = $user.SamAccountName
   $ou = "OU=30 mins,OU=2GB,DC=winopad,DC=com"
   $mail = $user.eMail

   New-ADUser -name $displayname -surname $nom -givenname $prenom -displayname $displayname -samaccountname $login -accountpassword (convertto-securestring $pass -asplaintext -force) -Path $ou -EmailAddress $mail -enabled $true  
}





$users = import-csv -delim ";" -path "C:\test\UsersToBeCreated.csv" 
foreach($user in $users)
{
   $pass = "Password2011"
   $nom = $user.Surname
   $prenom = $user.GivenName
   $displayname = $prenom+" "+$nom
   $login = $user.SamAccountName
   $ou = "OU=" + $user.OU +",OU=UTILISATEURS,DC=domain,DC=local"
   $description = $user.Description
   $fonction = $user.Fonction
   $mail = $user.Mail
   $drive = $user.Share
   $directory = $user.DirectoryShare+$login
   $phone = $user.PhoneNumber

   New-ADUser -name $displayname -surname $nom -givenname $prenom -displayname $displayname -samaccountname $login -accountpassword (convertto-securestring $pass -asplaintext -force) -Path $ou -description $description -title $fonction -EmailAddress $mail -HomeDrive $drive -HomeDirectory $directory -OfficePhone $phone -enabled $true  
}

Useful list of MS Exchange 2010/SP1 commands hosted mode


New-SendConnector -Name 'To Internet' -Usage 'Custom' -AddressSpaces 'SMTP:*;1' -IsScopedConnector $false -DNSRoutingEnabled $true -UseExternalDNSServersEnabled $false -SourceTransportServers 'domain.co.uk'

set-sendconnector “To Internet” –fqdn domain.co.uk

Get-ExchangeCertificate -DomainName domain.co.uk | Enable-ExchangeCertificate -Services SMTP

Set-ReceiveConnector -PermissionGroups 'AnonymousUsers, ExchangeUsers, ExchangeServers, ExchangeLegacyServers' -Identity 'WEBHOST\Default WEBHOST'
Get-ReceiveConnector "Default *" | Set-ReceiveConnector -PermissionGroups:AnonymousUsers,ExchangeUsers,ExchangeServers

Get-ReceiveConnector "Default *"  | Format-list

Set-ReceiveConnector “WEBHOST\Default WEBHOST” -MaxMessageSize 40Mb
Set-ReceiveConnector “WEBHOST\Client WEBHOST” -MaxMessageSize 40Mb

Increase sending size to 100 MB for all send connectors
get-sendconnector "*" | Set-Sendconnector -MaxMessageSize 100mb


Add-RoleGroupMember "Organization Management" -Member administrator

New-AcceptedDomain -Name "MyDomain" -DomainName domain.com -DomainType InternalRelay
Set-AcceptedDomain -Identity "Domain\Org" -DomainType Authoritative

New-AcceptedDomain -Organization "organization" -Name "COmpany" -DomainName domain.co.uk -DomainType Authoritative


New-SendConnector -Name "domain.com Send Connector" -Internet -AddressSpace domain.com -DNSRoutingEnabled $false -SmartHosts 78.78.78.78 -SmartHostAuthMechanism "None" -MaxMessageSize 20MB
New-SendConnector -Name "organization Send Connector" -Internet -AddressSpace organization.co.uk -DNSRoutingEnabled $false -SmartHosts 78.129.227.77 -SmartHostAuthMechanism 'None' -MaxMessageSize 20MB


Relay
New-ReceiveConnector -Name "Webhosting" -Usage Custom -PermissionGroups AnonymousUsers -Bindings 79.79.79.79:25 -RemoteIpRanges 78.78.78.78
New-ReceiveConnector -Name Webhosting -usage Custom -Bindings '79.79.79.79:25' -fqdn domain.co.uk -RemoteIPRanges 79.79.79.79 -server WEBHOST -permissiongroups ExchangeServers -AuthMechanism 'TLS, ExternalAuthoritative'


New-ReceiveConnector -Name "Company" -usage Custom -Bindings '79.79.79.79:25' -fqdn domain.co.uk -RemoteIPRanges 78.129.227.142 -server WEBHOST -permissiongroups ExchangeServers -AuthMechanism 'TLS, ExternalAuthoritative'

Get-ReceiveConnector "WEBHOST\Company" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"


Internal domains relay
New-SendConnector -Name "organization" -Usage "Custom" -AddressSpaces "SMTP:organization.co.uk;1" -IsScopedConnector $false -SmartHosts 79.79.79.79 -DNSRoutingEnabled $false -SmartHostAuthMechanism "None" -UseExternalDNSServersEnabled $false -SourceTransportServers "domain.co.uk"
(this above must be configured for every hosted domain on the server)


Set product key
Set-ExchangeServer -Identity WEBHOST -ProductKey X8JBR-24DFV-444OY-WX8H2-K2FCC

Working with Send connectors

Get-SendConnector "domain.com Send Connector" | Format-List
Set-SendConnector "domain.com Send Connector" -SmartHosts 78.78.78.78
Set-SendConnector "domain.com Send Connector" -MaxMessageSize 40Mb
Remove-SendConnector "domain.com Send Connector"


Add-MailboxPermission "John Doe" -User "Joe Public" -AccessRights FullAccess
(add permissions)

Anti Spam (copy paste should work)
Add-IPBlockListProvider -Name "BarracudaCentral" -LookupDomain "b.barracudacentral.org" -BitMaskMatch 127.0.0.2
Set-IPBlockListProvider "BarracudaCentral" -RejectionResponse "Message Rejected by Barracuda Central."


Add-IPBlockListProvider -Name bl.spamcop.net -LookupDomain bl.spamcop.net -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://www.spamcop.net/w3m?action=checkblock&ip={0} for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name dnsbl.sorbs.net -LookupDomain dnsbl.sorbs.net -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://www.au.sorbs.net/lookup.shtml for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name zen.spamhaus.org -LookupDomain zen.spamhaus.org -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://www.spamhaus.org/query/bl?ip={0} for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name cbl.abuseat.org -LookupDomain cbl.abuseat.org -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://cbl.abuseat.org/lookup.cgi?ip={0} for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name b.barracudacentral.org -LookupDomain b.barracudacentral.org -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://barracudacentral.org/lookups/ip-reputation for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name spam.dnsbl.sorbs.net -LookupDomain spam.dnsbl.sorbs.net -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://www.au.sorbs.net/lookup.shtml for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name spam.rbl.msrbl.net -LookupDomain spam.rbl.msrbl.net -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://www.msrbl.com/check?ip={0} for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name bl.spamcannibal.org -LookupDomain bl.spamcannibal.org -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://spamcannibal.org/cannibal.cgi for further information. This organization has no control over this RBL (Realtime Block List)."
Add-IPBlockListProvider -Name psbl.surriel.com -LookupDomain psbl.surriel.com -Enabled $True -RejectionResponse "{1} has blocked your IP address ({0}) using the list '{2}'. Please see http://psbl.surriel.com/listing?ip={0} for further information. This organization has no control over this RBL (Realtime Block List)."

Set-IPBlockListConfig -Enabled $true

set-transportserver "WEBHOST" -antispamagentsenabled $true

End of Antispam commands

Increase max message size
Set-TransportConfig -MaxReceiveSize 40MB -MaxSendSize 40MB


Enable SMTP logging
Set-ReceiveConnector “WEBHOST\Default WEBHOST” -ProtocolLoggingLevel verbose

Set-SenderReputationConfig -SenderBlockingEnabled $true -OpenProxyDetectionEnabled $true

(change default accepted domain)
Get-EmailAddressPolicy def* | Set-EmailAddressPolicy -EnabledEmailAddressTemplates 'SMTP:@organization.local' 

(create new accepteddomain)
New-AcceptedDomain -Name "Local" -DomainName organization.local -DomainType InternalRelay 
(make it default)   
Set-AcceptedDomain -Identity "Local" -DomainType Authoritative -MakeDefault $true    


Change default email address
New-AcceptedDomain -Name “organization”-DomainName organization.co.uk -DomainType Authoritative -Organization "organization"
Set-AcceptedDomain -Identity "organization\organization" -DomainType Authoritative -MakeDefault $true
New-EmailAddressPolicy -Name “@organization.co.uk”-IncludedRecipients MailboxUsers -Organization "organization" -Priority 1 -EnabledEmailAddressTemplates “SMTP:@organization.co.uk”
Update-EmailAddressPolicy -Identity “organization\@organization.co.uk”
Set-Mailbox john@organization.com –EmailAddresses SMTP:john@organization.co.uk

Set-Mailbox -identity "company\test@test.com" -emailaddresspolicyenabled $false –EmailAddresses SMTP:test1@test.com

SMTP via 587 remove sending delay
Set-ReceiveConnector "WEBHOST\Client WEBHOST" -MaxAcknowledgementDelay 0

Set-AcceptedDomain -Identity "organization\organization" -DomainType InternalRelay
New-AcceptedDomain -Organization "Company" -Name "Gmail" -DomainName gmail.com -DomainType Authoritative
Set-Mailbox user@domain.com –EmailAddresses SMTP:user@gmail.com


Set mailbox access permissions
Set-Mailbox "organization\Company Support" -EmailAddressPolicyEnabled $false
Set-Mailbox "organization\Company Support" –EmailAddresses SMTP:support@free-vps.co.uk
Add-MailboxPermission "organization\Company Support" -User "john Doe" -AccessRights FullAccess
Add-ADPermission "Company Support" -User "john Doe" -Extendedrights "Send As"


(set global mailbox quotas)
Set-MailboxDatabase -Identity "Mailbox Database 1513447900" -IssueWarningQuota 4GB -ProhibitSendQuota 5GB -ProhibitSendReceiveQuota 5GB -QuotaNotificationSchedule "Sun.2:00-Sun.3:00","Wed.2:00-Wed.3:00"


get all mailbox sizes in a nice layout
Get-MailboxStatistics -database “Mailbox Database 1513447900” | Select DisplayName, LastLoggedOnUserAccount, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime | Sort-Object TotalItemSize –Descending | Format-Table



Set-ReceiveConnector "WEBHOST\Client WEBHOST" -MaxAcknowledgementDelay 0
Set-AcceptedDomain -Identity "organization\organization" -DomainType InternalRelay
New-AcceptedDomain -Organization "Company" -Name "Gmail" -DomainName gmail.com -DomainType Authoritative
Set-Mailbox user@domain.com –EmailAddresses SMTP:user@gmail.com


Enable IMAP and POP3
Set-service msExchangeIMAP4 -startuptype automatic
Start-service msExchangeIMAP4

Set-service msExchangePOP3 -startuptype automatic
Start-service -service msExchangePOP3


Publish settings to OWA
Set-POPSettings -ExternalConnectionSettings "domain.co.uk:110:tls"
Set-IMAPSettings -ExternalConnectionSettings "domain.co.uk:143:tls"

Set-ReceiveConnector -Identity "WEBHOST\Client WEBHOST" -AdvertiseClientSettings:$true


Enable RPC over HTTP
Enable-OutlookAnywhere -Server 'domain.co.uk' -ExternalHostname 'domain.co.uk' -DefaultAuthenticationMethod 'NTLM' -SSLOffloading $false


View/amend organization quotas
Get-RecipientEnforcementProvisioningPolicy -Organization Company| fl
Set-RecipientEnforcementProvisioningPolicy -Identity “Company\Recipient Quota Policy” -MailboxCountQuota 10 -MailUserCountQuota 10

List all accepted domains for all hosted organizations
get-accepteddomain *\*


Enable and assign SSL certificate to the following services. Usually IIS is also in the list
Enable-ExchangeCertificate -Server 'WEBHOST' -Services 'IMAP, POP, SMTP' -Thumbprint '8FB34D1B40EFF76A663BA3D0123EC41F1795D794'
Enable-ExchangeCertificate -Server 'WEBHOST' -Services 'IMAP, POP, SMTP' -Thumbprint '1CD841B8E6AD573A9CF607C0BB2E02C8E115C615'


Get-ExchangeCertificate [-Thumbprint ] [-DomainController ] [-DomainName ] [-Server ]


Restart POP and IMAP services after certificate application
net stop MSExchangePOP3
net start MSExchangePOP3

net stop MSExchangeIMAP4
net start MSExchangeIMAP4

Create new unathenticated relay via server
New-ReceiveConnector -Name Webserver -Usage Custom -PermissionGroups AnonymousUsers -Bindings 0.0.0.0:25 -RemoteIpRanges 78.78.78.78
Get-ReceiveConnector Webserver | Add-ADPermission -User “NT AUTHORITY\ANONYMOUS LOGON” -ExtendedRights “Ms-Exch-SMTP-Accept-Any-Recipient”
Set-ReceiveConnector Webserver -MaxMessageSize 40MB

if cannot logon to EMC due to red message. Usually iisreset helps.
set-transportconfig -MaxReceiveSize 100MB -MaxSendSize 100MB


Enable Out Of Office for external recipients
Set-RemoteDomain -AllowedOOFType 'External' -Identity 'Default'


Setting external URLs for various services
Set-OWAVirtualDirectory –Identity "WEBHOST\owa (Default Web Site)" -ExternalURL https://domain.co.uk/OWA
Set-OABVirtualDirectory –Identity "WEBHOST\OAB (Default Web Site)"  -ExternalURL https://domain.co.uk/OAB
Set-WebServicesVirtualDirectory –Identity "WEBHOST\EWS (Default Web Site)" -ExternalURL https://domain.co.uk/ews/exchange.asmx
Set-ActiveSyncVirtualDirectory –Identity "WEBHOST\Microsoft-Server-ActiveSync (Default Web Site)" -ExternalURL https://domain.co.uk/Microsoft-Server-ActiveSync
Set-ECPVirtualDirectory –Identity "WEBHOST\ECP (Default Web Site)" -ExternalURL https://domain.co.uk/ECP


Useful links:
http://technet.microsoft.com/en-us/library/bb123545.aspx
http://www.allspammedup.com/2010/11/exchange-2010ip-blocklist-providers-in-exchange-2010/
http://jacobddixon.wordpress.com/2011/03/06/exchange-2010-sp1-multi-tenant-step-3-of-3/
http://mhlavaty.wordpress.com/2011/08/31/how-to-change-recipient-quota-policy-on-exchange-2010-hosted-mode/#comment-6



How to upgrade/Downgrade Windows 7 installation


Go to
HKLM/Software/Microsoft/Windows NT/CurrentVersion

change EditionID to be Professional
and Product name to be Windows 7 Professional

Then install Windows and click upgrade.

How to Sync Shared Gmail calendar with iPhone


Android phones will sync your email, contacts, and all of your calendars by just singing into your Gmail account. If you have an iPhone however, you will miss out on contact syncing if you set up your account as a Gmail account.
There is another option. You can set up your Gmail account as an Exchange account and be able to sync your email, contacts, and calendar, but by default it will only sync your primary calendar.
To add additional calendars you need to open your Safari browser on your iPhone and go to http://m.google.com/sync
Sign in with your Google account and then select which phone you want to change your sync settings on.
Select which calendars you would like sync with your phone.
Open your calendar app and open calendars in the top left corner. You should now see multiple calendars listed under your account instead of just the primary one you had before.
If you don’t, hit the refresh button in the bottom left corner or just give it 5-10 minutes to pull in your new calendars. If the calendars still do not show up, go to your settings app and remove your Gmail account and then add it again.
Once you see your shared calendars, check the ones you want to view by default in the calendar app and you are all set.
If you have problems with the m.google.com/sync web page not forwarding properly from your mobile browser you can also go to https://www.google.com/calendar/iphoneselect from your computer’s browser to turn on and off calenders for your iPhone. This will bypass the device selection but may work for non-iOS devices connected to Gmail via Exchange.

PHP 5.3 and IIS, XAMPP, Apache - slow loading


To fix this it is as easy as changing your database connection from using a hostname (such as localhost or server.com), and instead using an IP address (such as 127.0.0.1 or 192.168.1.2). After a quick restart of IIS to make sure the changes get applied page loads are back down where I expect them to be.


change configuration of mysql files to be 127.0.0.1 instead of localhost




Hi guys, my problem was a name resolution issue all because I had the skip-name-resolve in my my.ini in the wrong spot. It was in [mysql] when in fact it should be in [mysqld]. Fixed my own problem in the end but not without a bit of debugging first..

Joomla JsmallFIb userbound parameter


{jsmallfib [USERBOUND] abspath(c:\user files)} will get you to c:\user files\username where username is the logon name of the person logged in (e.g. jsmith)

XAMPP Apache PHP how to increase upload limit


How can you increase the PHP upload limit?
This can be done with the php.ini file. Here is how you do it:
Create a file under public_html and name it php.ini (if you do not have one yet.) Put the following in it:
upload_max_filesize = 5M
post_max_size = 5M
Replace the 5 with 20 or less. If you are letting other people upload, a size cap protects your storage space from abuse/overuse.
You will then need to add this line to a .htaccess file: (Please replace "yourusername" with your cpanel user name an add to the end of the comand line the folder(s) to the location of the php.ini file - Also there is a space between path and /home)
suPHP_ConfigPath /home/Yourusername/public_html
Now your PHP upload limit should be increased.

VMWare ESXi how to import a HDD from another ESXi foreign disk


esxcfg-volume -l  - list volumes, find UUID


VMFS3 UUID/label:  4dd52c33-b742ddde-cdc1-001e670402c1/SBS-Datastore
Can mount:  Yes
Can resignature:  Yes
Extent name:  naa.6003005700ed60001666bf1f70936030:1     range: 0 - 476671 (MB)


esxcfg-volume -M 4dd52c33-b742ddde-cdc1-001e670402c1


You need to tell it to detect the existing datastore: 
esxcfg-advcfg -s 1 /LVM/EnableResignature
esxcfg-advcfg -s 0 /LVM/DisallowSnapshotLun

Scan the volume:
esxcfg-rescan vmhba0 && esxcfg-rescan vmhba1
vmhba0 and vmhba1 are the volumes on your system.

Then login with the vi client:
Configuration ->Storage
Select Rescan
Which will scan for:
New storage adapters.
Scan for new VMFS volumes.

Click Refresh
Then go back to the summary and change the name of datastore from
snap-blah

To:
datastore1 or whatever name you want. 
Then turn the resignature option off.
esxcfg-advcfg -s 0 /LVM/EnableResignature
esxcfg-advcfg -s 1 /LVM/DisallowSnapshotLun

We create a 5 GB volume to install esxi on, so we can reinstall esxi without affecting the existing datastore(s).

VMWare Virtual machine only shows 4 CPUs instead of 8


Setting the number of cores per CPU in a virtual machine
Purpose
This article provides information on setting number of cores per CPU in a virtual machine.

Resolution
Some operating system SKUs are hard-limited to run on a fixed number of CPUs. For example, Windows Server 2003 Standard Edition is limited to run on up to 4 CPUs. If you install this operating system on an 8-socket physical box, it runs on only 4 of the CPUs. The operating system takes advantage of multi-core CPUs so if your CPUs are dual core, Windows Server 2003 SE runs on up to 8 cores, and if you have quad-core CPUs, it runs on up to 16 cores, and so on.
Virtual CPUs (vCPU) in VMware virtual machines appear to the operating system as single core CPUs. So, just like in the example above, if you create a virtual machine with 8 vCPUs (which you can do with vSphere) the operating system sees 8 single core CPUs. If the operating system is Windows 2003 SE (limited to 4 CPUs) it only runs on 4 vCPUs.

Note: Remember that 1 vCPU maps onto a physical core not a physical CPU, so the virtual machine is actually getting to run on 4 cores.

Considering that 1 vCPU is equal to 1 CPU is an assumption for the sake of simplification, since vCPUs are scheduled on logical CPUs which are hardware execution contexts. These tasks can take a while in the case of a single core CPU, CPUs that have only 1 thread per core, or could be just a thread in the case of a CPU that has hyperthreading.

Consider this scenario:

In the physical world you can run Windows 2003 SE on up to 8 cores (using a 2-socket quad-core box) but in a virtual machine they can only run on 4 cores because VMware tells the operating system that each CPU has only 1 core per socket.
VMware now has a setting which provides you control over the number of cores per CPU in a virtual machine.
This new setting, which you can add to the virtual machine configuration (.vmx) file, lets you set the number of cores per virtual socket in the virtual machine.

To implement this feature:
1.     Power off the virtual machine. 
2.     Right-click on the virtual machine and click Edit Settings. 
3.     Click Hardware and select CPUs. 
4.     Choose the number of virtual processors. 
5.     Click the Options tab. 
6.     Click General, in the Advanced options section. 
7.     Click Configuration Parameters. 
8.     Include cpuid.coresPerSocket in the Name column. 
9.     Enter a value (try 2, 4, or 8) in the Value column.

Note: Ensure that the number of vCPUs is divisible by the number of  cpuid.coresPerSocket in the virtual machine. That is, when you divide the number of vCPUs by the number of cpuid.coresPerSocket, it must return an integer value. For example, if your virtual machine is created with 8 vCPUs, coresPerSocket can only be 1, 2, 4, or 8.

The virtual machine now appears to the operating system as having multi-core CPUs with the number of cores per CPU given by the value that you provided in step 9.
10.  Click OK. 
11.  Power on the virtual machine. 
For example:
Create an 8 vCPU virtual machine and set cpuid.coresPerSocket = 2. Window Server 2003 SE running in this virtual machine now uses all 8 vCPUs. Under the covers, Windows sees 4 dual-core CPUs. The virtual machine is actually running on 8 physical cores.

Note:
·       Only values of 1, 2, 4, 8 for the cpuid.coresPerSocket are supported for the multi-core vCPU feature in ESX 4.x. 
·       In ESX 4.0, if multi-core vCPU is used, hot-plug vCPU is not permitted, even if it is available in the UI. 
·       Only HV 7 virtual machines support the multi-core vCPU feature. 
Important: When using cpuid.coresPerSocket, you should always ensure that you are in compliance with the requirements of your operating system EULA (Regarding the number of physical CPUs on which the operating system is actually running).

MySQL How to change column Order


ALTER TABLE `students` MODIFY COLUMN `first_name` varchar(50) AFTER `last_name`

MySQL How to change column Order


ALTER TABLE `students` MODIFY COLUMN `first_name` varchar(50) AFTER `last_name`

MySQL how to turn off Strict mode


Open your "my.ini" file within the MySQL installation directory, and look for the text "sql-mode".
Find:

Code:
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Replace with:

Code:
# Set the SQL mode to strict
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Or, you can run an SQL query within your database management tool, such as phpMyAdmin:


Code:
SET @@global.sql_mode= '';

MySQL XAMPP How to Export Stored Procedures and triggers


MySQL 5 has introduced some new interesting features, like stored procedures and triggers.
I will show in this small post how we can backup and restore these components usingmysqldump.
mysqldump will backup by default all the triggers but NOT the stored procedures/functions. There are 2 mysqldump parameters that control this behavior:
  • –routines – FALSE by default
  • –triggers – TRUE by default
This means that if you want to include in an existing backup script also the triggers and stored procedures you only need to add the –routines command line parameter:
mysqldump --routines > outputfile.sql 
Let’s assume we want to backup ONLY the stored procedures and triggers and not the mysql tables and data (this can be useful to import these in another db/server that has already the data but not the stored procedures and/or triggers), then we should run something like:
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt > outputfile.sql

and this will save only the procedures/functions/triggers of the . If you need to import them to another db/server you will have to run something like:
mysql < outputfile.sql

Working example:

Works on XAMPP:

mysqldump --user root --password=p1ssw0rd --routines --no-create-info --no-data --no-create-db --skip-opt mydatabase > c:\mydatabase_procs.sql




How to upgrade MacBook Air to Mac OSX Lion




A few things to keep in mind.
1.  Reinstalling Lion will not reinstall iLife. You will have to redownload iMovie, iPhoto, and Garage band from the App store.


Fist method: installing Lion from the net
1.  Turn on your computer, holding the option key+power key.
2. Let go of the power key while maintaining hold on the option key.
3. Use your cursor to select your network under "choose your network"
4. Select recovery hd
5. Select reinstall Mac osx
6. Wait for the download and installation process. This should take about 45min to 9 hours. This time variation really depends on your network speed.

Second method: installing from an Apple Lion USB drive or a Self made InstallESD.dmg USB drive
1.  Turn on your computer, holding the option key+power key.
2. Let go of the power key while maintaining hold on the option key.
3.  Select the Lion recovery USB or your self made InstallESD.dmg USB disk which should appear on your right most option.
4. Select reinstall Mac osx
5 wait for about 30mins to 1 hour.

MacBook Mac OSX startup commands


During boot if you press:
C You start from a bootable CD such as your install DVD in the drive.
D Perform an Apple Hard ware test if you have your install DVD in the drive.
N Boot from a network compatible server. Only useful if you have the server.

T Start up in Target Disk mode. You can usually connect to another Mac through Firewire and do lots of funky things. Gone out of fashion and not used as much.
Option Start up using the Start Up Manager. Here you can pick which drive you want to boot from. Known to people who use BootCamp. You can also boot from a CD which is the same as press C.
Option then N Similar to the item above, except you get given the choice of booting from a network disk.
Option + N Boot from the first network boot image.
Command + V Boot up in Verbose mode, where you see lots of text whizzing by which is not a lot of use to you. I have written about this command here. It will also show Verbose output on shut down.
Command + S Single User Mode. This is where you can run a lot of high level tasks as a single user. Probably not for newbies. You could probably break your computer very quickly in Single User mode. More about it here.
Shift Start up in safe mode. Very useful if you have a problem and need an environment where you don’t want unnecessary things loaded. A good bet if you get Kernel panics during boot.
Option + Command + P + R Reset NVRAM. Although you will probably never need to reset this RAM it contents some useful stuff that can become corrupted. If you are having really bad problems this may be a good lead to follow. More information on Apple’s website.
Hold Eject or F12 or Mouse Eject anything that is in the disk drive. One to follow on from yesterdays topic.
I think that is just about it. I couldn’t find any more that worked with Mac OS X. If you have any more please leave a comment below. Its useful to have a list in case you ever need to use them.

How to Record Internal System Audio on Mac OSX



Have you ever not found a song you wanted on iTunes? Annoying, right? For me, I typically find my music on SadSteve or YouTube (yes — YouTube). A while ago, MacHeist hosted a mission which included some handy applications, such as WireTap Pro. At first, I had no reason to use this application, then I discovered its amazing capabilities for recording line-in audio (e.g. YouTube music videos). Unfortunately, Ambrosia Software feels that it’s necessary to make WireTap Pro ridiculously expensive ($69). I believe it’s important to make money as a software developer, but that’s just insane. Due to the fact, many of you reading this tutorial either did not win the mission on MacHeist (two years ago) or you don’t want to spend $69 on WireTap Pro, I’m going to show you how to record (streaming) audio for free, with Audacity.
  1. Download AudacitySoundflower (special audio plugin, free), and LAME MP3 Encoder (exports MP3).
  2. Open up Soundflower in /Applications/Soundflower/Soundflowerbed.
  3. Click the Soundflower icon in the menubar.
  4. Make sure under Soundflower (2ch) “Built-in Output” is selected.
  5. Open up the Sound preference pane in System Preferences.
  6. In both the Output and Input sections, select Soundflower (2ch).
  7. Open up Audacity, and go to Preferences.
  8. In the Devices section, set Soundflower (2ch) as the Recording Device and 2 (Stereo) as the Recording Channels.
  9. Leave “Built-in Output” as the Playback device.
  10. In Audacity Preferences, go to the Libraries section.
  11. Click the Locate button next to MP3 Library.
  12. The location should be “/usr/local/lib/audacity/libmp3lame.dylib”. Click Browse, then click Open to load it.
  13. Click OK. You may need to quit and re-open Audacity for the MP3 library to work.
  14. Finally, the moment you’ve been waiting for…
  15. Go to YouTube and type in the name of the song you want. Select the music video for the song.
  16. Click the record button in Audacity (red circle button) and start recording the song from the YouTube music video.
  17. When the song is over, click the stop button (yellow square button) in Audacity.
  18. Go to File > Export.
  19. Type in the song information (title, year, genre, artist). Click OK.
  20. In the Save As window, type in the song title as the filename. Change the Format to MP3 Files.
  21. Click Options if you want to adjust the MP3 settings. Then click Save.
  22. Import the song file into your iTunes library.
  23. Done.

Mac OSX how to show routing table


"netstat -nr" will display the routing tables. 
The '-r' displays the routing tables, 
and the '-n' flag makes sure the display show numerical addresses instead of trying to resolve host/network/port names. 

How to flush DNS cache on Mac OSX


I primarily work with web servers, and I use lookupd -flushcache all of the time to clear my DNS cache.

This morning was moving some websites around using my newly-upgraded Mac, and I went to flush my DNS cache with lookupd and I got a command not found error. It seems that lookupd has been removed in 10.5 and replaced with dscacheutil.

So now I can flush my DNS cache with dscacheutil -flushcache

Apple Authorised repair stores in Egypt


Appleline
Cairo
Tel: (002-02) 7951200 / 7922614, Fax: (002-02) 7943886
e-mail: appleline@appleline.com.eg

ApplePie
Cairo
Tel: (002-02) 3470328 / 3037132, Fax: (002-02) 3049208

Best Buy- HEAD OFFICE
Telephone : (+202) 7923238 - 7950596
Fax : (+202) 7923237
Best Buy- STORE
Telephone : (+202) 7628391/2 - 3367527/8
Fax : (+202) 3367523
Website: Best Buy - Cite

Appliance
Citystar, Grandhayat, Agamy-Sportingclub, Alex

Best Buy - Apple Center
Al-Thawra Square, Mohandessin
Cairo, Egypt
Tel: 00202 7628391 - 00202 7628392 - 00202 3367527 - 00202 3367528
Carrefour HyperMarkets
Contact Person : Mr. Ashraf Maqlad
Address: Dandy Mega Mall, Cairo-Alex Desert Road
City Center Mall, Ring Road Mirage City, Maadi, Cairo, Egypt.

HyperOne
EL sheikh Zayed city, 6 october, Cairo

Phono Stores
Contact Person : Mr. Mohamed Khalifa
Address : 28, Abd Al-Moneim Riad St., Mohandesseen, Giza, Egypt.

Radioshack

Radwan Al Ogeil Stores
Mostafa Mahmoud Square, Mohandseen, Cairo
Tel: +202 3389573
+202 3389575
+2012 2104471

Rizk Allah Stores
Contact Person : Mr. Maged Nabil
Address: 102B, Al-Marghany St., Heliopolis.

Spinneys HyperMarket
Contact Person: Mr. Sherif El-Saharty
Address : CITY STARS mall, 1st Floor, Heliopolis, Cairo, Egypt
Virgin Megastore
Contact Person : Mr. Abeer Daou
E-mail address : abeer.daou@azalgroup.com
Address : CITY STARS mall, 2nd Floor, Heliopolis, Cairo, Egypt
Compume
Tel:4802330
Address: Citystars Mall 1 st floor,Heliopolis,Cairo.

Turn any MP3 into iPhone ringtone


  • Start iTunes and find the song you want to convert. (It must be an MP3.)
  • Right-click the song and choose Get Info.
  • Click the Options tab.
  • Check the Start Time and Stop Time boxes, then enter times for each (no more than 30 seconds apart, the maximum length for a ringtone). I used 0:00 and 0:30, respectively, as "Spit It Out" has a perfect ascending lead-in.
  • Click OK, then right-click the song again and choose Create AAC Version. You should immediately see a new 30-second version of the song.
  • Drag that version out of iTunes and into the folder of your choice.
  • Delete the 30-second version from iTunes and undo the Start Time/Stop Time changes to the original.
  • Open the folder containing the 30-second AAC file you dragged out of iTunes, then change the file extension from .m4a to .m4r. Double-click it and it immediately gets added to iTunes' ringtone library.
  • Finally, sync your iPhone. When it's done, you can head into the settings and select your new ringtone.