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…
Say you have a simple XML file books.xml that looks like this:
<?xml version="1.0" encoding="UTF-8"?> <books> <book> <author> <name>Nikola</name> <surname>Brežnjak</surname> </author> <title>Some awesome book title</title> <year>2014</year> </book> <book> <author> <name>Patrick</name> <surname>Rothfuss</surname> </author> <title>Doors of stone</title> <year>20xx</year> </book> </books>
and you want to get all the names of the authors, you can use SimpleXML:
<?php $xml = simplexml_load_file("books.xml"); var_dump($xml); $data = array(); foreach ($xml as $book){ $data[] = (string)$book->author->name; } var_dump($data); ?>
Every time I read a book I write quotes to my notebook, but also when I come across some good random quote I put it in as well. Just recently I filled up one of my “quote notebooks” so now I’ll post all the quotes from this notebook that are not “book specific” but instead spread throughout this notebook randomly. Not all books I read are in English, as you can see in the image, but I’ll be posting just those here…
And the day you finally decide to love will be the day that I have given up on chasing you.
Everyone is expendable.
The girl changed you and you don’t even know it.
Maybe God has a bigger plan for me then I have for myself.
There is no such thing as an ex con.
How do you pick up the threads of an old life? How do you go on, when in your heart you begin to understand that there is no going back? There are some things that time cannot mend.
Relationships are like glass. Sometimes it’s better to leave them broken them to hurt yourself putting in back together.
They say that people come in your life for a reason.
Enemy of my enemy is my friend.
Love till you hate, strong do you break.
You’ll learn, she said. Though it did not sound as an encouragement.
What if you were told that you could make a fortune just by pushing a button on a box? By pressing the button will simultaneously cause the death of another human being somewhere in the world. Someone you don’t know. Would you still push the button?!
When I do good I feel good. When I do bad, I feel bad. That’s my religion.
How much I missed simply because I was afraid of missing.
If I had a list of all the people that might come to visit me in prison, your name would be at the bottom. Somewhere below Jesus Christ and Scooby Doo.
The love is nothing, to be loved is something, to love and be loved is everything.
You’re just jealous because the voices are talking to me.
Pain is temporary pride is forever!
She’s the kind of woman that would rather go to sleep then to tap out.
If God made everything then he must be from China.
You don’t love a woman because she’s beautiful, she’s beautiful because you love her.
True love does not have a happy ending. True love doesn’t have an ending.
Come, live in my heart, and pay no rent.
Enjoy life but to be attentive. Don’t think there are no beast just because the forest is silent.
Hi, I’m a spider and I can make your girlfriend scream louder than you can.
I have learned to never assume too much when it comes to form users.
If you cant explain it to a six-year-old, you don’t understand it yourself.
When you really love someone age, distance, height, weight is just a darn number.
I’ve missed more than 9000 shots in my career. I lost almost 300 games. 26 times have been trusted to take the game winning shot and missed. I’ve failed over and over again in my life. And that is why I succeed.
It’s not that we don’t like you, we hate you. Period!
Hacker. Dropout. CEO.
I don’t get it why do people always assume the worst, when you tell them you’re a drug dealer.
Someday, and that day may never come, I may call upon you to do a service for me. But, until that day, accept this as a gift.
Life is so short, so why think about dying?
They killed God because he smiled on them.
They’ll bury it so deep it’ll be easier to reach if you start digging in China.
Why do we never know ourselves the way we think we do.
Once you know what you’re looking for, the rest comes easy.
The man who passes the sentence should swing the sword.
It’s uncomfortable to focus so intensely on what you’re bad at,” Spiegel told me. “So the way people usually study chess is they read a book about chess, which can be fun and often intellectually amusing, but it doesn’t actually translate into skill. If you really want to get better at chess, you have to look at your games and figure out what you’re doing wrong.
Spiegel wrote on her blog: The first day and a half was pretty bad. I was on a complete rampage, going over every game and being a huge bitch all the time: saying things like “THAT IS COMPLETELY UNACCEPTABLE!!!” to 11-year-olds for hanging pieces or not having a reason for a move. I said some amazing things to kids, including “You can count to two, right? Then you should have seen that!!” and “If you are not going to pay more attention, you should quit chess, because you are wasting everyone’s time.” By the end of round three I was starting to feel like an abusive jerk and was about to give up and be fake nice instead. But then in round four everyone took more than an hour and started playing well. And I really believe that’s why we seem to win girls’ nationals sections pretty easily every year: most people won’t tell teenage girls (especially the together, articulate ones) that they are lazy and the quality of their work is unacceptable. And sometimes kids need to hear that, or they have no reason to step up.
Disclaimer: I’m in no way affiliated with Nodejitsu or any of the frameworks that I listed below in the post. I’m just documenting my experience with them – problems (and solutions) I’ve faced while trying these new technologies on a Windows machine.
MEN – MongoDB, Express, Node.js, and if you think MEN is not mean enough, take a look at the post on Deploying MEAN.io to Nodejitsu from Windows machine.
Nodejitsu is a cloud platform as a service based on Node.js and serves Node.js applications on their platform. Signup is free, you don’t have to enter billing info in order to try 2 months free (yes, databases work too!), just click on the “Do not select a product now” button:
After signing up you get a confirmation mail like this:
Welcome to Nodejitsu! Your Nodejitsu account is activated and ready to go! username: userName To confirm your account, install the latest jitsu: sudo npm install jitsu -g and then run: jitsu users confirm userName big-h@5h This will allow you to deploy applications with: jitsu deploy
Setting up databases in the web admin interface is easy as you only have to literally click one button after deciding which database type and provider you want:
Hackaton starters are gaining momentum and there are quite a few of them already like:
- Hackaton starter
- Drywall
- DozerJS
- Skeleton
- MEAN – only one which offers Angular out of the box (a follow up post on this is here)
I decided to try out Skeleton, mainly because I liked the “just right” Goldilocks reference 🙂
So, as the site suggests, you first have to installnodemon , gulp andmocha , then clone the github repo, npm & bower install everything and you’re done:
# Install global dependencies npm install -g nodemon gulp mocha # Clone the repoo (and fetch only the latest commits) git clone --depth=1 [email protected]:dstroot/skeleton.git cd skeleton # Install local dependencies npm install bower install # Start everything up with Gulp # (builds the assets and starts the app with nodemon) gulp
Everything works for you? Great! For the rest of unlucky ones, you may got (like me) after running gulp :
gulp module.js:340 throw err; ^ Error: Cannot find module 'jshint-stylish' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (C:\Users\Nikola\Desktop\skeleton\gulpfile.js:22:21) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)
I tried npm install jshint-stylish , and ran gulp again:
C:\Users\Nikola\Desktop\skeleton>gulp [gulp] Using gulpfile C:\Users\Nikola\Desktop\skeleton\gulpfile.js [gulp] Starting 'clean'... [gulp] Finished 'clean' after 11 ms [gulp] Starting 'styles'... [gulp] Starting 'scripts'... [gulp] Starting 'images'... [gulp] Finished 'images' after 2.75 ms [gulp] Starting 'lint'... [gulp] Finished 'lint' after 192 ms [gulp] Starting 'watch'... [gulp] Finished 'watch' after 151 ms [gulp] Starting 'develop'... [gulp] Finished 'develop' after 1.68 ms [gulp] Live reload server listening on: 35729 [gulp] gulp-notify: [Gulp notification] Clean task complete events.js:72 throw er; // Unhandled 'error' event ^ Error: Incorrect OS. node-notify requires Mac OS 10.8 or higher at C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\node_modules\no de-notifier\lib\terminal-notifier.js:46:25 at Object.module.exports.isMacOSX (C:\Users\Nikola\Desktop\skeleton\node_mod ules\gulp-notify\node_modules\node-notifier\lib\utils.js:24:12) at Notifier.notify (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notif y\node_modules\node-notifier\lib\terminal-notifier.js:44:11) at module.exports (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify \lib\report.js:17:5) at Transform._flush (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-noti fy\lib\notify.js:41:5) at Transform.<anonymous> (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp -notify\node_modules\through2\node_modules\readable-stream\lib\_stream_transform .js:130:12) at Transform.g (events.js:180:16) at Transform.EventEmitter.emit (events.js:92:17) at finishMaybe (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\no de_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:363:12) at endWritable (C:\Users\Nikola\Desktop\skeleton\node_modules\gulp-notify\no de_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:370:3)
As the message says (note also on their website), gulp notify , which uses node-notify is not supported on Windows. The way I solved this was that I removed all of the .pipe(notify({ onLast: true, message: ‘Scripts task complete’ })) lines from gulpfile.js, but it still wasn’t enough! Running lint job made the gulp fail, so I removed that to and woila then it all worked.
A note (though you can look this up on the official github page also) on how to setup Google login by:
- Visit Google Cloud Console
- Click CREATE PROJECT button
- Enter Project Name, then click CREATE
- Then select APIs & auth from the sidebar and click on Credentials tab
- Click CREATE NEW CLIENT ID button
- Application Type: Web Application
- Authorized Javascript origins: http://localhost:3000
- Authorized redirect URI: http://localhost:3000/auth/google/callback
- Copy and paste Client ID and Client secret keys into
config/config.js
Note: When you ready to deploy to production don’t forget to add your new url to Authorized Javascript origins and Authorized redirect URI, e.g. http://my-awesome-app.nodejitsu.com
and http://my-awesome-app.nodejitsu.com/auth/google/callback
respectively. The same goes for other providers.
Deploying to Nodejitsu is done by firstly loging in and then executing jitsu deploy:
C:\Users\Nikola\Desktop\skeleton>jitsu login info: Welcome to Nodejitsu hitman666 info: jitsu v0.13.15, node v0.10.26 info: It worked if it ends with Nodejitsu ok info: Executing command login prompt: username: (hitman666) prompt: password: info: Authenticated as hitman666 info: Nodejitsu ok C:\Users\Nikola\Desktop\skeleton>jitsu deploy
Boom, your app is live on Nodejitsu server and it should look like this (ofc YMMV in term of link):
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:
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.
My favorite quotes from the book The Wise Man’s Fear by Patrick Rothfuss:
I don’t care what they talk, I care what they say.
There was an art to choosing your projects in fishery. It didn’t matter if you made the brightest sympathy lamp or the most efficient heat funnel in the history of artificing until someone bought it you wouldn’t make a bent penny of commission.
Most things fail with the age. Our hands and basks stiffen, our eyes dim, skin roghens and our beauty fades. The only exception is the voice. Properly cared for a voice does nothing but grow sweeter with age and constant use.
We love what we love. So, yes, it had flaws, so what does that had to matter when it comes to the matters of the heart. We love what to love. Reason does not enter into it. In many ways unwise love is the truest love. Anyone can love a thing ‘because’. That’s as easy as putting a penny in your pocket. But to love something ‘despite’, to know the flaws, and love them too. That is rare end pure and perfect.
Why Auri? Because she doesn’t have anyone else, and neither do I. If we don’t look out for each other – who will?
The desire for a knowledge shapes the mind
The second was some rather bad poetry, but it was short and I forced my way through gritting my teeth and occasionally closing one eye, so it is not to damage the entirety of my brain.
If we didn’t have impressive sounding names no one would take us seriously.
You’d be amazed how similar arrogance and confidence look at first glance. And he was generous and rich – which is a nice combination.
Clothes do not make a man, but you need a proper costume if you want to play the part.
They were the best sort of friends. The sort everyone hopes for but no one deserves.
When you’re around it’s easy to forget all the bad parts of my life – who I am – it’s nice to take a vacation from myself every once in a while. You’re my safe harbor in an endless stormy sea. You’re my shady willow on a sunny day. You’re sweet music in a distant room. You’re unexpected cake on a rainy day. You’re my bright penny on the roadside, you are worth more than the moon on the long night walk. You are sweet wine in my mouth, a song in my throat and laughter in my heart. You’re too good for me. You are a luxury I cannot afford. Despite this I insist you come with me today, I will buy you dinner and spend hours waxing rhapsodic landscape of wonder that is you.
Lord woman, if I had tits like yours I’d own half the world by now.
Poetry is a song without music. The song without music is like a body without soul.
Too much looking can get in the way of seeing.
The world needs people like you. You get things done. Not always the best or most sensible way but it gets done. You’re a rare creature. You know exactly what to do. You don’t hesitate – you just see and react.
That’s another problem with power. If you possess too much people don’t date point out your mistakes.
I’ll need to know more about her. Trying to court a woman without knowing her would be worse than foolish.
History tends to be rather dry, but everyone enjoys story.
It’s hard to long for something that is always there. Absence feeds affection.
A secret of the mouth is like a stone in a boot. At first you’re barely aware of it, then grows irritating, then intolerable. Secrets of the mouth grow larger the longer you keep them swelling until they press against your lips. They fight to be let free. Secrets of the heart are different. They are private and painful and we want nothing more than to hide them from the world. They do not swell or press against the mouth, they live in the heart and a longer they are kept the heavier they become. He complains that it’s better to have a mouthful of poison than the secret of a heart. Any fool will spit out poison, but we support these painful treasures. We swallow hard against them every day, forcing them deep inside us. There they sit, growing heavier – given the time they cannot help but crush the heart that holds them.
Nothing in the world is harder than convincing someone of an unfamiliar truth.
Only a fool worries over what he can’t control
Half of seeming clever is keeping your mouth shut at the right times.
Boys are always wearing beards hoping it will make them men.
Leader is not the muscle leader is a mind.
I learned more from a month on the road then I had in three years of classes. No man is brave that has never walked a hundred miles. If you want to know the truth of who you are walk until not a person knows your name. Travel is the great leveler, a great teacher. Bitter as medicine, cruder than glass. Long stretch of road will teach you more about yourself than 100 years of quiet introspective.
But sometimes the best help a person can find is helping someone else.
If a leg goes bad you need to cut it off, and some folks need killing.
They did important things. They made hard choices that no one else was willing to do. That sort of thing frightens people.
It’s one thing to enjoy story but it’s quite another to take it for the truth.
My problem started with not being able to install gulp. I checked my npm version (npm –version ) and saw I have version 1.2.32 whilst the time of this writing the newest version was 1.4.3. After countless trying of commands like
npm cache clean npm update -g npm npm update npm install gulp -g
and reinstalling Node.js from official site I realized that even though I removed my Node.js installation from C:\Program Files\nodejs I still had it in C:\Program Files (x86). Doh! :/ So, after I removed both installations, I redownloaded the exe file from Nodejs.org and installed to C:\nodejs. After this, when I ran npm install gulp everything went well. However, when I tried to install it globally (npm install gulp -g ) I got:
npm ERR! peerinvalid The package generator-karma does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer [email protected] wants generator-karma@~0.6.0 npm ERR! peerinvalid Peer [email protected] wants generator-karma@>=0.6.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" "gulp-util" "-g" npm ERR! cwd C:\Users\Nikola\Desktop\skeleton npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! code EPEERINVALID npm ERR! npm ERR! Additional logging details can be found in: npm ERR! C:\Users\Nikola\Desktop\skeleton\npm-debug.log npm ERR! not ok code 0
Then I uninstalled npm uninstall -g generator-karma and npm uninstall -g generator-angular , and gulp installed fine.
Heroku is a cloud platform as a service supporting several programming languages which lets app developers spend their time on their application code, not managing servers, deployment, ongoing operations, or scaling…
If you tried to get your feet wet with Heroku by deploying Node.js application, you must have come across this article on Heroku’s documentation (and you also may have run into problems when starting Foreman if you’re on a Windows machine – read onward to see how I’ve solved it).
Obviously, first you have to make an account on Heroku, then install Heroku toolbelt (it gives you git, foreman, and heroku command line interface) for your environment (in my case Windows):
Fire up your command prompt (I use Console2) and run heroku login . You need to have Node.js installed (in case you don’t you can download it here).
Write some Node.js app and put it in app.js file:
//app.js var express = require("express"); var app = express(); app.get('/', function(req, res) { res.send('Every day in every way I\'m serving more requests'); }); var port = Number(process.env.PORT || 5000); app.listen(port, function() { console.log("Listening on " + port); });
If you have package.json file then Heroku will recognize your app as Node.js app. In order to create it, run npm init in the root directory of your app. The npm init utility will walk you through creating a package.json file by asking few questions. If you already made your repository on GitHub and cloned it locally then npm init command in this folder will recognize that too and add:
"repository": { "type": "git", "url": "https://github.com/yourUsername/appName.git" }
If you wish, you can freely clone my test app from Github: https://github.com/Hitman666/herokuTestApp.git
Next, install dependencies from your code (in app.js example the required module is express). Use npm install <pkg> –save to install a package and save it as a dependency in the package.json file. In my example that would be one command:
npm install express --save
You have to set a Procfile, which is a text file in the root directory of your application, to explicitly declare what command should be executed to start a web dyno. In our case this would be the contents of Procfile:
web: node app.js
Now you should be able to start your application locally using Foreman (installed as part of the Heroku Toolbelt) by running foreman start .
But here the party started :/
In my case foreman didn’t start at all, and after a lot of searching, I managed to solve it in few steps. First, I updated my Ruby installation:
gem update --system --source http://rubygems.org/
Then, according to this StackOverflow post I installed former version of foreman:
gem uninstall foreman gem install foreman -v 0.61
Finally, I added Ruby’s bin folder (Ruby which, in my case, is in C:\Program Files (x86)\Heroku\ruby-1.9.2\bin) to my PATH variable.
Ok, almost there! Lets add our app to git (you should skip the git init command if you already cloned your app from GitHub):
git init git add . git commit -m "init"
and finally, lets deploy it to Heroku:
heroku create git push heroku master
To open the app in your browser run heroku open . To push the changes to GitHub you have to execute git push origin master.
*Now that your app is up and running on heroku (my link) you may want to prevent it from going to sleep mode. Some suggestions on how to achieve this are in this post on StackOverflow (I went with UptimeRobot).
**At some point, as I was fiddling with the apps on Heroku’s website, I deleted all apps and then the git push heroku master command from my console was not working anymore, so I had to do:
git remote rm heroku heroku create git push heroku master
***Also, I wanted to rename my app and that can be done easily:
heroku apps:rename NEWNAME
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.
Recent posts
- Fireblocks Cryptocurrency Scams: A Real-Life Example
- Getting started with React by building a Pokemon search application
- Espanso: Because Who Actually Likes Typing Out Their Emails?
- Getting started with Vue.js 3 by building a Pokemon search application
- Solving the ‘Retry as Admin’ while saving files in Visual Studio Code on a Mac
Categories
- Android (3)
- Books (114)
- Programming (22)
- CodeProject (35)
- Daily Thoughts (71)
- Go (3)
- iOS (5)
- JavaScript (127)
- 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)
- Stack Overflow (81)
- Unity3D (9)
- Windows (8)
- Wordpress (2)