Author Archives: admin

VBA environment variables (ENVIRON)

To see a list of variables, create a sub:

 
Sub ListEnvironmentVariables()

    'each environment variable in turn
    Dim EnvironmentVariable As String
    
    'the number of each environment variable
    Dim EnvironmentVariableIndex As Integer
    
    'get first environment variables
    EnvironmentVariableIndex = 1
    EnvironmentVariable = Environ(EnvironmentVariableIndex)
    
    'loop over all environment variables till there are no more
    Do Until EnvironmentVariable = ""
    
    'get next e.v. and print out its value
    Debug.Print EnvironmentVariableIndex, EnvironmentVariable
    
    'go on to next one
    EnvironmentVariableIndex = EnvironmentVariableIndex + 1
    EnvironmentVariable = Environ(EnvironmentVariableIndex)
    
    Loop

End Sub
 

click menu “View” > “Immediate Window” and run it
Doesn’t work on macintosh

Private Sub Workbook_Open()
'Generates a GUID:
Sheet1.Cells(8, 3).Value = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)  

'environment variables:
Sheet1.Cells(11, 3).Value = Environ$("computername")  
Sheet1.Cells(12, 3).Value = Environ$("username")
Sheet1.Cells(13, 3).Value = Environ$("USERPROFILE")
 
MsgBox "Hello " & Environ$("username")

End Sub

on Macintosh Excel you can try a AppleScript, something like:

Function GetUserNameMac() As String
    Dim sMyScript As String

    sMyScript = "set userName to short user name of (system info)" & vbNewLine & "return userName"

    GetUserNameMac = MacScript(sMyScript)
End Function

Warning: Cannot modify header information – headers already sent by ..

error message:

Warning: Cannot modify header information – headers already sent by (output started at C:\…\…\…\…\filexpto.php:1) in C:\…\…\…\…\….php on line xx

 

resolution:

open file filexpto.php and add ob_start(); like

 
<?php
ob_start();
....

 

ob_startTurn on output buffering

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

 
more in:
http://www.php.net/manual/en/function.ob-start.php
 

Import multiple vCards to Gmail contacts manager

Need to concatenate all the VCFs in to a single file

# get a command prompt
Windows_Key + R
run: cmd
# change to the directory where all your VCFs are located
e:
cd vcf
# Run this command

copy   /B   *.vcf   all.vcf

Then upload the “all.vcf” file to google

IIS6 and Office 2007 MIME types

Error message:

 

    HTTP Error 404 – File or directory not found.
Internet Information Services (IIS)

Since Office 2007 was released after Windows Server 2003 and IIS6, IIS6 knows nothing about the new MIME types. So you need to manually add them:

Open Computer Management. (Right-click My Computer… Manage…)
Right-click Internet Information Services (IIS) Management… Properties…
Click MIME Types…
Click New… and add the following:

Extension     MIME Type
.xlsx     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx     application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx     application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx     application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx     application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx     application/vnd.openxmlformats-officedocument.presentationml.slide
.docx     application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx     application/vnd.openxmlformats-officedocument.wordprocessingml.template
.xlam     application/vnd.ms-excel.addin.macroEnabled.12
.xlsb     application/vnd.ms-excel.sheet.binary.macroEnabled.12

Detect invalid(sintax) emails

Detect invalid(sintax) emails in db

SELECT * FROM people WHERE email NOT LIKE '%_@__%.__%'

Query to list number of records in each table in a database

sql server 2005



SELECT 
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY 
    t.Name, s.Name, p.Rows
ORDER BY 
    t.Name





DBeaver is free and open source (GPL) universal database tool

DBeaver is free and open source (GPL) universal database tool for developers and database administrators.

  • Usability is the main goal of this project, program UI is carefully designed and implemented.
  • It is freeware.
  • It is multiplatform.
  • It is based on opensource framework and allows writing of various extensions (plugins).
  • It supports any database having a JDBC driver.
  • It may handle any external datasource which may or may not have a JDBC driver.
  • There is a set of plugins for certain databases (MySQL and Oracle in version 1.x) and different database management utilities (e.g. ERD)

http://dbeaver.jkiss.org/about/ read more »

Sendy.co, newsletter simple and cheap

Sendy is a self hosted email newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES).

This makes it possible for you to send authenticated bulk emails at an insanely low price without sacrificing deliverability.

Email service Cost per 10,000
MailChimp $200
Campaign Monitor $105
Amazon SES $1

read more »

Edit files on the linux command line

To edit files on the command line, you can use an editor such as vi. To open the file, run

vi /path/to/file

Now you see the contents of the file (if there is any. Please note that the file is created if it does not exist yet.).
The most important commands in vi are these:
Press i to enter the Insert mode. Now you can type in your text.
To leave the Insert mode press ESC.
To delete the character that is currently under the cursor you must press X (and you must not be in Insert mode because if you are you will insert the character x instead of deleting the character under the cursor). So if you have just opened the file with vi, you can immediately use x to delete characters. If you are in Insert mode you have to leave it first with ESC.
If you have made changes and want to save the file, press : x (again you must not be in Insert mode. If you are, press ESC to leave it).
If you haven’t made any changes, press :q to leave the file (but you must not be in Insert mode).
If you have made changes, but want to leave the file without saving the changes, press :q! (but you must not be in Insert mode).
Please note that during all these operations you can use your keyboard’s arrow keys to navigate the cursor through the text.

Check your newsletter content quality

Low quality content means, a high percentage of your emails did not get pass the ISP’s spam filters and got sent to spam immediately. ISP means the receiving end, eg. gmail, hotmail, yahoo mail, etc.

Try using this tool to check your spam score: http://www.contactology.com/check_mqs.php

Or this tool (you need to paste in full headers of your email: http://spamcheck.postmarkapp.com/

If you’ve been sending emails to people who did not opt-in to receive your emails, most people will mark your emails as spam. Overtime, you’ll accumulated a high spam score.