# Cache Control with .htaccess # from <a href="http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html" >http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html</a> # 3 Month <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=7257600" </FilesMatch> # 1 Week <FilesMatch ".(js|css|pdf|txt)$"> Header set Cache-Control "max-age=604800" </FilesMatch> # 10 Minutes <FilesMatch ".(html|htm)$"> Header set Cache-Control "max-age=600" </FilesMatch> # NONE <FilesMatch ".(pl|php|cgi|spl)$"> Header unset Cache-Control Header unset Expires Header unset Last-Modified FileETag None Header unset Pragma </FilesMatch> # TIME CHEAT SHEET # 300 5 MIN # 600 10 MIN # 900 15 MIN # 1800 30 MIN # 2700 45 MIN # # 3600 1 HR # 7200 2 HR # 10800 3 HR # 14400 4 HR # 18000 5 HR # 36000 10 HR # 39600 11 HR # 43200 12 HR # 46800 13 HR # 50400 14 HR # 54000 15 HR # 86400 24 HR # # 86400 1 DAY # 172800 2 DAY # 259200 3 DAY # 345600 4 DAY # 432000 5 DAY # 518400 6 DAY # 604800 7 DAY # # 604800 1 WEEK # 1209600 2 WEEK # 1814400 3 WEEK # 2419200 4 WEEK # # 2419200 1 MONTH (FEBRUARY) # 2505600 1 MONTH (FEBRUARY LEAP YEAR) # 2592000 1 MONTH (APRIL, JUNE, SEPTEMBER, NOVEMBER) # 2678400 1 MONTH (JANUARY, MARCH, MAY, JULY, AUGUST, OCTOBER, DECEMBER) # 31536000 12 MONTH
Cache Control with htaccess FILES MATCH
Xml Config Entry to Write out Temporary Assemblies Created for the Serializers
<system.diagnostics> <switches> <add name="XmlSerialization.Compilation" value="4"/> </switches> </system.diagnostics>
foreach in c++ (#define)
#define foreach(m_itname,m_container) for( typeof(m_container.begin()) m_itname=m_container.begin() ; m_itname!=m_container.end() ; m_itname++ )
Permissão de gravação em pasta
string sPath = Path.GetDirectoryName(Application.ExecutablePath);
string sTmpPath = sPath + "Temp";
// ********* REMOVER *************
//MessageBox.Show("Path: " + sTmpPath, "Tz0 info", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (!Directory.Exists(sTmpPath))
Directory.CreateDirectory(sTmpPath);
// Pega a segurança atual da pasta
DirectorySecurity oDirSec = Directory.GetAccessControl(sTmpPath);
// Define o usuário Everyone (Todos)
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
//SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
NTAccount oAccount = sid.Translate(typeof(NTAccount)) as NTAccount;
oDirSec.PurgeAccessRules(oAccount);
FileSystemAccessRule fsAR = new FileSystemAccessRule(oAccount,
FileSystemRights.Modify,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
// Atribui a regra de acesso alterada
oDirSec.SetAccessRule(fsAR);
Directory.SetAccessControl(sTmpPath, oDirSec);
One liner perl extract content with regular expression
curl -s <a href="http://checkip.dyndns.org" >http://checkip.dyndns.org</a> | perl -nle 'print "$1" if (/Current IP Address: ([d.]*)/)'
add plpgsql support in postgresql(Linux)
su postgres -c "/usr/lib/postgresql/8.2/bin/createlang plpgsql <databaseName>"
ref
String.prototype.ref = function () {
for (var args = [], i = 0; i < arguments.length; i++)
args.push('arguments[' + i + ']');
if (window[this] && window[this] instanceof Function)
return eval('(new window.' + this + '(' + args.join(',') + '))');
throw new Error('Function window.' + this + ' does not exist.');
};
Tags: js
Drag n Drop
/*****************************
import Classes
*****************************/
import fl.video.FLVPlayback;
//Drag and Drop Manager
import flash.desktop.DragManager;
import flash.desktop.ClipboardFormats;
//Event that Handles the Drag and Drop Events
import flash.events.NativeDragEvent;
/*****************************
Create an active Hit Spot
*****************************/
var shape:Shape = new Shape();
shape.graphics.beginFill(0x000000, 1);
shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
shape.graphics.endFill();
var _mc:MovieClip = new MovieClip();
_mc.addChild(shape);
addChild(_mc);
var video_vd:FLVPlayback = new FLVPlayback();
addChild(video_vd);
video_vd.x = 0;
video_vd.y = 0;
video_vd.width = 320;
video_vd.height = 240;
/*****************************
Drag and Drop
*****************************/
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragEnter);
function onDragEnter(e:NativeDragEvent):void {
//NativeDragEvent has a clipboard property where our data is stored. That clipboard class has a getData method
//The way to specifiy formats is the a constant of a ClipboardFormats class. We just want a file object
//The reason it is a filelist is because if multiple files were dragged into the Flash, all of them could be retreived
var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT);
//Check the File Extension of the Object
if (fa[0].extension == "flv") {
//Accept the Drag n Drop operation
DragManager.acceptDragDrop(this);
}
}
this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
function onDragDrop(e:NativeDragEvent):void {
var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT);
video_vd.play(fa[0].url);
}
Tags: as3
Exception Logging to the Event Log
Public MustInherit Class ExceptionLogger Protected mstrEventSource As String Public Sub WriteToEventLog(ByVal strMessage As String, ByVal enmType As EventLogEntryType) Try If (Not EventLog.SourceExists(mstrEventSource)) Then EventLog.CreateEventSource(mstrEventSource, "Application") End If EventLog.WriteEntry(mstrEventSource, strMessage, enmType) Catch ex As Exception End Try End Sub Public Sub LogException(ByVal objException As Exception, Optional ByVal strClassName As String = "", Optional ByVal strMethodName As String = "") Dim objStackFrame As StackFrame = New System.Diagnostics.StackFrame(1) Dim intLineNumber As Integer = objStackFrame.GetFileLineNumber() Dim strFile As String = objStackFrame.GetFileName ' If no class/method information was passed in, get the information from the call stack If (strClassName = "" And strMethodName = "") Then Dim objMethod As System.Reflection.MethodBase = objStackFrame.GetMethod() strClassName = objMethod.ReflectedType.FullName strMethodName = objMethod.Name End If Dim strMessage As String = "Exception Details:" & ControlChars.CrLf If (strClassName <> "") Then strMessage = strMessage & "Class:" & ControlChars.Tab & strClassName & ControlChars.CrLf End If If (strMethodName <> "") Then strMessage = strMessage & "Method:" & ControlChars.Tab & strMethodName & ControlChars.CrLf End If If (intLineNumber <> 0) Then strMessage = strMessage & "Line:" & ControlChars.Tab & intLineNumber & ControlChars.CrLf End If If (strFile <> "") Then strMessage = strMessage & "File:" & ControlChars.Tab & strFile & ControlChars.CrLf End If strMessage = strMessage & "Details:" & ControlChars.Tab & objException.Message & ControlChars.CrLf ' Walk through all innerExceptions, adding their message to the combined message If (Not objException.InnerException Is Nothing) Then strMessage = strMessage & ControlChars.CrLf & "Inner exceptions:" & ControlChars.CrLf Dim objExceptionWalker As Exception = objException While (Not objExceptionWalker.InnerException Is Nothing) objExceptionWalker = objExceptionWalker.InnerException strMessage = strMessage & ControlChars.CrLf & "Message:" & ControlChars.CrLf strMessage = strMessage & objExceptionWalker.Message & ControlChars.CrLf End While End If WriteToEventLog(strMessage, EventLogEntryType.Error) End Sub Public Sub New() mstrEventSource = My.Application.Info.Title End Sub Public Sub New(ByVal strEventSource As String) mstrEventSource = strEventSource End Sub End Class