Drupal - GeSHi Filter

In Drupal 7, go to admin/config/content/formats/filtered_html and make sure that under the Filter processing order, GeSHi filter is below Limit allowed HTML tags.

Varia - Timesheet

Create Timesheet online.

Javascript - Remove element by tag name

function removeElementByTagName(tagName)
{
	var element = document.getElementsByTagName(tagName);
	for (index = element.length - 1; index >= 0; index--)
	{
		element[index].parentNode.removeChild(element[index]);
	}
}

Javascript - Sort multidimensional array

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>                                                                 
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    //<![CDATA[
      //========================================================
      // Example showing how to sort multi-dimensional arrays.
      //========================================================
 
      var persons = [
              // First    , Last    , Age

Javascript - Internet Explorer unknown runtime error with element.innerHTML

Don't use element.innerHTML to add HTML string to an element. It will cost Unknown Runtime Error from Internet Explorer. However, other browsers(e.g. Firefox, Chrome) don't complain and work properly.
Instead, use document.createElement(), document.createTextNode(), element.appendChild() to create the complete structure.

DOS - Relative file path

You can call the script below and filter what you want with find like the following:

CALL relative_file_path.bat | find /I ".doc"

@ECHO OFF
REM Display relative file path
SETLOCAL DisableDelayedExpansion
SET "r=%__CD__%"
FOR /R . %%F IN (*) DO (
  SET "p=%%F"
  SETLOCAL EnableDelayedExpansion
  ECHO(!p:%r%=!
  ENDLOCAL
)

Solution from:
http://stackoverflow.com/questions/8385454/batch-files-list-all-files-in-a-directory-with-relative-paths

DOS - Generate a M3U file per folder

REM Description: Generate a M3U file per folder.
REM   -You need to change "C:\Your\MP3\folder\path\" to match your folder path.
REM   -Multilingual is limited by DIR command.
REM Requirements: -You need SED installed.
 
FOR /R "C:\Your\MP3\folder\path\" %%G IN (.) DO (
CALL :Create_M3U "%%G"
)
ECHO "Other commands here after the loop."
 
GOTO :EOF
 
:Create_M3U
  PUSHD %1

  REM Format the directory name.
  ECHO %1 > tmpfile.txt
  sed -i "s/\\\.//" tmpfile.txt
  sed -i "s/.*\\//" tmpfile.txt
    REM Clean up directory name.

ABAP - Date Time manipulations

REPORT  Z_DATE_TIME.
 
DATA: LV_DATE TYPE D,
      LV_TIME TYPE T,
      LV_DATE_TIME TYPE STRING.
 
LV_DATE = SY-DATUM.
LV_TIME = SY-UZEIT.
 
WRITE: / 'Current Date:', LV_DATE MM/DD/YYYY.
WRITE: /(60) LV_TIME USING EDIT MASK 'Current Time: __:__:__'.
 
* Put date and time into a string.
CONCATENATE LV_DATE(4) LV_DATE+4(2) LV_DATE+6(2) INTO LV_DATE_TIME SEPARATED BY '-'.
CONCATENATE LV_DATE_TIME '_' LV_TIME(2) '.' LV_TIME+2(2) '.' LV_TIME+4(2) INTO LV_DATE_TIME.
WRITE: / LV_DATE_TIME.

ABAP - String manipulations

Concatenation

Concatenate integers with strings:

REPORT  zconcatenate_int_string.
DATA:
      lv_string TYPE string,
      lv_int TYPE i VALUE 9.
 
*CONCATENATE works with string only.
* Therefore, you must cast the integer as a string 
*   by assigning the integer variable into a string variable.
lv_string = lv_int.
CONCATENATE 'The value is:' lv_string INTO lv_string.
 
WRITE: / lv_string.

Trimming

Remove leading and trailing spaces:

REPORT  Z_REMOVE_SPACES.
 
DATA: STR TYPE STRING.

ABAP - Calculate the runtime

REPORT  Z_GET_RUNTIME.
* Note: GET RUN TIME returns microseconds. If the elapse time is too long, it may overflow the integer data types.
 
DATA: T1 TYPE I,
      T2 TYPE I,
      ELAPSED TYPE I.
 
* Get the time and put in T1.
GET RUN TIME FIELD T1.
 
* Wait 3 seconds.
CALL FUNCTION 'ENQUE_SLEEP'
  EXPORTING
    SECONDS = 3.
 
* Get the time and put in T2.
GET RUN TIME FIELD T2.
 
* Calculate the different between T2 and T1.
ELAPSED = T2 - T1.            " In microseconds.
ELAPSED = ELAPSED / 1000000.  " In seconds.
 
* Display the runtime.

Syndicate content