Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
NodeJS, Quick tips

How to delete node_modules folder on Windows machine?

Due to its folder nesting Windows can’t delete the folder as its name is too long. To solve this, install RimRaf:

npm install rimraf -g

and delete the node_modules folder easily with:

rimraf node_modules

 

edit: If you happen to get an “error” like this:

C:\Users\Nikola\Desktop>npm install -g rimraf
C:\Users\Nikola\AppData\Roaming\npm\rimraf -> C:\Users\Nikola\AppData\Roaming\npm\node_modules\rimraf\bin.js
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\generator-ionic requires cordova@'^4.2.0' but will load
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\cordova,
npm WARN unmet dependency which is version 5.1.1
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\bower\node_modules\bower-registry-client requires request@'~2.51.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\bower\node_modules\fstream-ignore requires fstream@'^1.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm ERR! peerinvalid The package node-inspector does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants node-inspector@~0.7.0

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\NodeJS\\\\node.exe" "C:\\NodeJS\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "rimraf"
npm ERR! cwd C:\Users\Nikola\Desktop
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Nikola\Desktop\npm-debug.log
npm ERR! not ok code 0

Don’t panic :), just try to run rimraf instead, as noted above. In most cases, all will be okay and you’ll be able to use it without a problem. If not, head to the comments, and we’ll take care of it together! For those who don’t care much about comments, here’s the post in which I address this node-inspector issue.

How to delete node_modules folder on Windows machine? http://t.co/0pV4OSTG1L #nodejs #windows #node_modules

— Nikola Brežnjak (@HitmanHR) July 28, 2015

Quick tips

Enable continuous scrolling by default in Adobe Reader

Whenever I opened some pdf file and scrolled with the mouse the scrolling was per one page. Sure, you can change this by going to View -> Page Display -> Enable Scrolling:

enableScrolling

but once you reopen Adobe Reader it’s back to as it was.

The solution is to make the default setting for all documents to have this setting and you do this by going to Edit -> Preferences and selecting Accessibility -> Override Page Display and setting it to Single Page Continuous.

adobeReaderDefaultSettings

edit: Thanks to Hugo André’s comment, it seems that in newer versions this is found by going to: “Go to the tab Adobe Reader -> Preferences”.

Quick tips

How to make a print screen on a Mac keyboard on the Windows machine

This has been haunting me for some time now – there’s just no Print Screen key on this keyboard which works on a Windows machine.

If you take a look at this thread you’ll see numerous attempts of which only installing AppleKeys2 worked for me. Now I only press F13 and woila – it works the same as Print Screen on a normal Windows keyboard.

If for some reason the link for AppleKeys2 is not working anymore, you can download it here.

Quick tips, WPF

Maximizing WPF Window to second monitor

So, if you have this in the code behind:

if (System.Windows.Forms.Screen.AllScreens.Length >= Config.ScreenNumber)
{
    System.Drawing.Rectangle screenBounds = System.Windows.Forms.Screen.AllScreens[Config.ScreenNumber - 1].Bounds;
    this.Left = screenBounds.Left;
    this.Top = screenBounds.Top;
}

And this in your XAML file on Window:

<Window WindowState="Maximized" ...

Asuming that Config.ScreenNumber equals 2, it will not position itself on the second screen no matter what you do, it will maximize on your main screen. What helped in the end was to remove the WindowState from the XAML definition and to add Loaded event handler:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    this.WindowState = WindowState.Maximized;
}
Linux, Quick tips

Installing CasperJS on RHEL Linux distribution

First you have to install NodeJS. You can do that via package manager for your distribution. In my case (RHEL) it is easily done with:

sudo yum install nodejs npm --enablerepo=epel

Installing CasperJS is easy via npm (Node package manager):

sudo npm install -g casperjs

You will get output similar to this:

Copying extracted folder /usr/lib/node_modules/casperjs/node_modules/phantomjs/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2-extract-1396259124118/phantomjs-1.9.7-linux-x86_64 -> /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
/usr/bin/casperjs -> /usr/lib/node_modules/casperjs/bin/casperjs
npm WARN unmet dependency /usr/lib/node_modules/block-stream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-ignore requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-npm requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/glob requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/npmconf requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/tar requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
[email protected] /usr/lib/node_modules/casperjs
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[[email protected] ~]$ casperjs
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
[[email protected] ~]$ /usr/bin/casperjs
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
[[email protected] ~]$ /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
phantomjs>
[[email protected] ~]$ /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs --version
1.9.7

To have the binaries in my path every time I log in I added this alias to my .bashrc:

alias phantomset="export PATH=$PATH:/usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/"

and my .bash_profile looks like this:

# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
phantomset
Quick tips

Console 2 arrow keys not working

All of a sudden my arrow keys stopped working – up  and down keys scrolled the screen up and down, while left and right  had no effect. I found the solution here and basically all that you have to do is disable Scroll Lock on your keyboard! Pretty weird stuff, if I may add…

Quick tips

Customize Console 2 on Windows machine

If you’re using Console 2, and I don’t know why you wouldn’t want to btw, you probably wanted to customize it. Here is an excellent post by Scott Hanselman on how to do it:http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx.

To change settings you have to right-click in the main console and click Edit | Settings.

The settings that I have used from his blog are:

  • I’ve set Desktop as my startup directory under Console – Startup Directory
  • I hid the menu, status bar and toolbar under Appearance | More
  • I’ve set the font to Consolas, but font only 12, as 15 (as he suggests) looks way too big on my screen. No experimentation with matrix colors or transparency.
  • I’ve set the option so that when I select with the mouse the selection gets coppied into the clipboard by selecting “Copy on Select” under Behavior
  • Hotkeys, changed the New Tab 1 hotkey to Ctrl-T
  • Hotkeys, changed Paste to Ctrl-V
  • Do not use Ctrl-C as Copy Selection or you will not be able to break some command that keeps running after you run it (like grunt for example). And besides if you used my settings then you already have a “Copy on Select” option set. More info here: http://sourceforge.net/p/console/bugs/401/

edit (18.3.2014): So, it turned out I wanted to be matrix cool :), so I went to change the color of the font, but to no avail. Finally I figured out that actually the grey color needed to be changed to green and not white as I was doing. Here’s an image to make thing clearer:
console2_color

Quick tips

Git push origin master could not read username for http://github.com

If you clone your project on another computer and try to do:

git push origin master

and you get and error like:

fatal: could not read Username for ‘https://github.com’: No such file or directory

then you can solve this by executing the following command:

git remote set-url origin [email protected]:username/repo.git

where, of course,username  and repo  depend on your settings.

For more info, check this StackOverflow question.

 

NodeJS, Quick tips

How to use nodemon

Nodemon is a utility that will monitor for any changes in your source and automatically restart your server. Perfect for development. Install it using npm.

npm install -g nodemon

Once installed, instead of node app.js  use nodemon app.js . It will save you a lot of time in the long run, because you won’t need to manually restart the server each time you make a change.

edit: These days I’m using a ever so slightly more popular PM2.

Quick tips, Sublime Text, Windows

How to use JSHint in Sublime Text on Windows machine

Since this is in the “quick tips” category I won’t go into what Sublime Text is, or why using JSHint is recommended, and that for it’s installation you need Node.js, I will just state the shortest possible path in how to install it, as I had some problems in doing this in a timely fashion:

//install jshint via npm
npm install jshint -g

In Sublime Text install JSHint Gutter via package manager.

And now, finally, since I’m on a windows machine, the problem was that once I got all this installed I had to set the Node.js path in JSHint Gutter plugin but with setting the absolute path to node.exe by using forward slashes:

{
  // Simply using `node` without specifying a path sometimes doesn't work :(
  // https://github.com/victorporof/Sublime-JSHint#oh-noez-command-not-found
  // http://nodejs.org/#download
  "node_path": "C:/Program Files/nodejs/",

  // Automatically lint on edit (Sublime Text 3 only).
  "lint_on_edit": false,

  // Automatically lint when a file is saved.
  "lint_on_save": true,

  // Highlight problematic regions when selected.
  "highlight_selected_regions": false
}
Page 4 of 4«1234

Recent posts

  • Discipline is also a talent
  • Play for the fun of it
  • The importance of failing
  • A fresh start
  • Perseverance

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (35)
  • Daily Thoughts (77)
  • Go (3)
  • iOS (5)
  • JavaScript (127)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (2)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (77)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (40)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak