Thursday, June 28, 2012

node.Js and Express tips

Getting Started with Node.js & Express




Create node.cmd

@if "%_echo%"=="" echo off
call "C:\Program Files (x86)\nodejs\nodejsvars.bat"
PROMPT=[ Node.js $M$P ]$_
set PROMPT=[ Node.js $M$P ]$_
TITLE node 


Friday, May 25, 2012

directory listing excluding files

dir /s /b /a-r-d   | findstr /v /i ".suo$"



FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
        strings [[drive:][path]filename[ ...]]

  /B         Matches pattern if at the beginning of a line.
  /E         Matches pattern if at the end of a line.
  /L         Uses search strings literally.
  /R         Uses search strings as regular expressions.
  /S         Searches for matching files in the current directory and all
             subdirectories.
  /I         Specifies that the search is not to be case-sensitive.
  /X         Prints lines that match exactly.
  /V         Prints only lines that do not contain a match.
  /N         Prints the line number before each line that matches.
  /M         Prints only the filename if a file contains a match.
  /O         Prints character offset before each matching line.
  /P         Skip files with non-printable characters.
  /OFF[LINE] Do not skip files with offline attribute set.
  /A:attr    Specifies color attribute with two hex digits. See "color /?"
  /F:file    Reads file list from the specified file(/ stands for console).
  /C:string  Uses specified string as a literal search string.
  /G:file    Gets search strings from the specified file(/ stands for console).
  /D:dir     Search a semicolon delimited list of directories
  strings    Text to be searched for.
  [drive:][path]filename
             Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C.  For example, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y.  'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

Regular expression quick reference:
  .        Wildcard: any character
  *        Repeat: zero or more occurrences of previous character or class
  ^        Line position: beginning of line
  $        Line position: end of line
  [class]  Character class: any one character in set
  [^class] Inverse class: any one character not in set
  [x-y]    Range: any characters within the specified range
  \x       Escape: literal use of metacharacter x
  \<xyz    Word position: beginning of word
  xyz\>    Word position: end of word

For full information on FINDSTR regular expressions refer to the online Command
Reference.

Thursday, April 19, 2012

Notepad++ failed to load config.xml error

Fix is to reset the following file:

C:\Users\%USERNAME%\AppData\Roaming\Notepad++\config.xml

Contents:

<xml version="1.0" encoding="Windows-1252" ?>

<NotepadPlus>

<GUIConfigs>

<GUIConfig name="ToolBar" visible="yes">standardGUIConfig>

<GUIConfig name="StatusBar">showGUIConfig>

<GUIConfig name="TabBar" dragAndDrop="yes" drawTopBar="yes" drawInactiveTab="yes" reduce="yes" closeButton="no" doubleClick2Close="no" vertical="no" multiLine="no" hide="no" />

<GUIConfig name="ScintillaViewsSplitter">verticalGUIConfig>

<GUIConfig name="UserDefineDlg" position="undocked">hideGUIConfig>

<GUIConfig name="TabSetting" size="4" replaceBySpace="yes" />

<GUIConfig name="AppPosition" x="470" y="4" width="1162" height="993" isMaximized="yes" />

<GUIConfig name="ScintillaPrimaryView" lineNumberMargin="show" bookMarkMargin="show" folderMarkStyle="box" indentGuideLine="show" currentLineHilitingShow="show" Wrap="no" edge="no" edgeNbColumn="100" wrapSymbolShow="hide" zoom="-2" whiteSpaceShow="show" eolShow="hide" lineWrapMethod="aligned" zoom2="-1" borderWidth="2" />

<GUIConfig name="Auto-detection">autoGUIConfig>

<GUIConfig name="CheckHistoryFiles">noGUIConfig>

<GUIConfig name="TrayIcon">noGUIConfig>

<GUIConfig name="RememberLastSession">yesGUIConfig>

<GUIConfig name="NewDocDefaultSettings" format="0" encoding="0" lang="0" codepage="-1" openAnsiAsUTF8="no" />

<GUIConfig name="langsExcluded" gr0="0" gr1="0" gr2="0" gr3="0" gr4="0" gr5="0" gr6="0" gr7="0" langMenuCompact="yes" />

<GUIConfig name="Print" lineNumber="no" printOption="0" headerLeft="$(FULL_CURRENT_PATH)" headerMiddle="" headerRight="$(LONG_DATE) $(TIME)" headerFontName="IBMPC" headerFontStyle="1" headerFontSize="8" footerLeft="" footerMiddle="-$(CURRENT_PRINTING_PAGE)-" footerRight="" footerFontName="" footerFontStyle="0" footerFontSize="9" margeLeft="0" margeTop="0" margeRight="0" margeBottom="0" />

<GUIConfig name="Backup" action="0" useCustumDir="no" dir="" />

<GUIConfig name="TaskList">yesGUIConfig>

<GUIConfig name="SaveOpenFileInSameDir">noGUIConfig>

<GUIConfig name="noUpdate" intervalDays="15" nextUpdateDate="20080426">noGUIConfig>

<GUIConfig name="MaitainIndent">yesGUIConfig>

<GUIConfig name="MRU">yesGUIConfig>

<GUIConfig name="URL">0GUIConfig>

<GUIConfig name="globalOverride" fg="no" bg="no" font="no" fontSize="no" bold="no" italic="no" underline="no" />

<GUIConfig name="auto-completion" autoCAction="0" triggerFromNbChar="1" funcParams="no" />

<GUIConfig name="sessionExt">GUIConfig>

<GUIConfig name="SmartHighLight">yesGUIConfig>

<GUIConfig name="TagsMatchHighLight" TagAttrHighLight="yes" HighLightNonHtmlZone="no">yesGUIConfig>

<GUIConfig name="MenuBar">showGUIConfig>

<GUIConfig name="Caret" width="1" blinkRate="250" />

<GUIConfig name="ScintillaGlobalSettings" enableMultiSelection="no" />

<GUIConfig name="openSaveDir" value="0" defaultDirPath="" />

<GUIConfig name="titleBar" short="no" />

<GUIConfig name="stylerTheme" path="C:\Users\a-cgomes\AppData\Roaming\Notepad++\stylers.xml" />

<GUIConfig name="DockingManager" leftWidth="200" rightWidth="200" topHeight="200" bottomHeight="200">

<PluginDlg pluginName="dummy" id="0" curr="3" prev="-1" isVisible="yes" />

<ActiveTabs cont="0" activeTab="-1" />

<ActiveTabs cont="1" activeTab="-1" />

<ActiveTabs cont="2" activeTab="-1" />

<ActiveTabs cont="3" activeTab="-1" />

<GUIConfig>

<GUIConfigs>

<FindHistory nbMaxFindHistoryPath="10" nbMaxFindHistoryFilter="10" nbMaxFindHistoryFind="10" nbMaxFindHistoryReplace="10" matchWord="yes" matchCase="no" wrap="yes" directionDown="yes" fifRecuisive="yes" fifInHiddenFolder="no" dlgAlwaysVisible="no" fifFilterFollowsDoc="no" fifFolderFollowsDoc="yes" searchMode="0" transparencyMode="1" transparency="150">

<Path name="C:\temp" />

<FindHistory>

<History nbMaxFile="15" inSubMenu="no" customLength="-1">

<File filename="C:\temp\FullRun.log" />

<History>

<ProjectPanels>

<ProjectPanel id="0" workSpaceFile="" />

<ProjectPanel id="1" workSpaceFile="" />

<ProjectPanel id="2" workSpaceFile="" />

<ProjectPanels>

<NotepadPlus>

Wednesday, January 11, 2012

Adding new Activity to Android App Package

From: http://stackoverflow.com/questions/2337874/best-way-to-add-activity-to-an-android-project-in-eclipse

you can create the activity via the manifest editor like this:

  1. Double click on AndroidManifest.xml in the package explorer.
  2. Click on the "Application" tab of the manifest editor
  3. Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
  4. Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
  5. Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.

When you click Finish from the new class dialog, it'll take you to your new activity class so you can start coding.

Five steps might seem a lot, but I'm just trying to be extra detailed here so that it's clear. It's pretty quick when you actually do it.

Saturday, January 7, 2012

AppleScript to Toggle usage of bluetooth speakers

Here is a script I wrote that works around a Mac OS bug on the Mac Book Pro. The issue I was seeing, was that after opening the lid to my laptop, a previously connected bluetooth speaker could no longer be connected to.

Workaround:
I found that if I simply ran "Bluetooth Setup Assistant" before selecting "Use as Audio Device" then I could reliably connect to the bluetooth speakers. I am using the Creative Labs D200 speakers, which work well.

Script:

-- Start "Bluetooth Setup Assistant to trigger bluetooth mode

-- For some reason this reliably leads to connecting to the bluetooth speaker

tell application "Bluetooth Setup Assistant"

activate

delay 3

quit

end tell

-- Toggle usage of Bluetooth speakers

tell application "System Events" to tell the front menu bar of process "SystemUIServer"

activate

delay 1

tell menu bar item 1

click

-- Un comment next line for diagnostic mode

-- set menustuff to entire contents of front menu

-- Specify your bluetooth speaker name here in place of "Creative D200"

tell menu item "Creative D200" of menu 1

click

tell menu item 1 of menu "Creative D200"

click

end tell

end tell

end tell

-- Workaround below: Only when running this script as an application

-- For some reason running this script as an application doesn't perform the final click above, so I added an additional menu click below which cause the previous click to take effect.

-- repeat to add another action

tell menu bar item 1

click

tell menu item 1 of menu 1

click

end tell

end tell

end tell

-- Un comment next line for diagnostic mode

--return menustuff

Monday, November 14, 2011

Notepad++:
1. Show white space & Tab characters
View->Show all characters, or View->Show White Space and TAB

Trim Trailing Space & Save

Macro > Trim Trailing and save

--- Map this to Ctrl S

Remove the trailing spaces

TextFX > TextFX Edit > Trim Trailing Spaces

Wednesday, October 26, 2011

Samsung Galaxy S II 2 - Wifi and 4G on at same time.


Problem is that Wifi and 4G are on at same time at home, but no data is downloaded.

Solutions that I have found on the web / customer support:

Solution A
1. Navigate to Setttings -> Wireless and network -> Mobile networks
2. Uncheck Use packet data
3. Wait for Wifi to reconnect
4. Re-check Use packet data
5. Wati for 4G to come on and then dis-appear


Solution B

This happens whenever there is an app running that requires 4G and can't communicate over Wifi, most likely the T-Mobile My Account app. Try launching it (to bring it into the foreground), press Home, and then go to the Task Manager app to kill it.

Solution C

You could also try Llama from the market and try the following - it has worked wonders for my battery as well.



Turn off T mobils contact sync

menu -> settings -> accounts and sync -> uncheck T-Mobil contacts

Ensure mobile data is not active when connected to wifi - here is how

Install Llama from the Android Market

Add an event called WiFi

Add condition: WiFi connected (any network)

Add action: Wifi Sleep Policy (never sleep)

Add action: toggle Mobile Data (off)

Add another event called WiFi Disconnected

Add condition: WiFi disconnected (any network)

Add action: WiFi Sleep Policy (Sleeps when screen turns off)

Add action: Toggle Mobile Data (on)

This will clear up the dual wifi 4g issue + save you some battery