Weekly Roundup - 2 #npm #npmgate #go #ai


2015, Dublin - Oneplus One“The ones that love us never really leave us”.(Sirius Black (Harry Potter)) Internet is broken by an angry programmer who is totally right: I’ve Just Liberated My Modules A discussion about the breaking of the Internet Business insider explains the situation simply For people who uses npm for left-pad which was unpublished by Azer, can do this for fixing the builds: (Because code is still in github; just not in npm anymore) "dependencies": { "left-pad": "git+ssh://[email protected]:azer/left-pad"} OR shortcut: "dependencies": {"left-pad": "azer/left-pad"} Situation on the npm side:Fun fact: because of all the metadata, the javascript community downloads “isarray” in the excess of 100GB a month from npm. For a one linerTweet More JS comedy when it’s digged deeper: Tweet Reddit “Saturday night data mining: #golang contributors by date” Tweet New trend: Reply everything wi...

Redcarpet instead of kramdown as markdown renderer


Vieux Port de Montréal, October 2015 - Oneplus oneRedcarpet is the engine written in C by Github, It’s also known as Github flavored markdown. I’ve been using kramdown since the beginning but apparently redcarpet has some cool features like autolinking.For example if you put a link in your post without using <url> notation or [url text](url), kramdown does not convert those urls into <a> tags. Instead it renders them as raw text in <p> tag.Here is my config.yaml:markdown: redcarpetkramdown: input: GFM hard_wrap: falseredcarpet: extensions: ["autolink", "fenced_code_blocks"]Here is the full list of available redcarpet extensions:https://github.com/vmg/redcarpetBtw fenced codeblocks kicks ass, just put your code like this:```foo.bar()```

Serving subdomains of localhost, no apache2 conf needed


Trabzon, August 2015 - Oneplus OneFor my latest project, I implemented subdomain handling, however, I wasn’t able to test it from my local; pushing to production and try from the real domain and subdomain was so hard. When I look at the tutorials, they are mostly php stuff containing apache2 configurations, virtualhosts etc. I needed a simple method for this. Modify content of hosts file$ sudo nano /etc/hosts Example configuration127.0.0.1 localhost127.0.0.1 hakan.localhost Install web.py just for the sake of trial.$ sudo easy_install web.py Create a file$ touch main.py Paste this content:import web urls = ( '/(.*)', 'hello')app = web.application(urls, globals())class hello: def GET(self, name): if not name: name = 'World' return 'Hello, ' + name + '!'if __name__ == "__main__": app.run() Run the file.$ python main.pyOpen browser and go:

Rename files sequentially in a folder #bash


The output will be something like 0001.jpg, 0002.jpg etc. You can change the number of digits by modifying %04d part.a=1for i in *.jpg; do new=$(printf "%04d.jpg" "$a") #04 pad to length of 4 mv -- "$i" "$new" let a=a+1doneThanks SO

Weekly Roundup - 1


Flat Montreal is Flat - October, 2015 I read a lot of blog posts, RSS feeds, watch too many videos, solve too many big/little problem during the week. So instead of keeping them in my Keep; I decided to put small snippets here so that I can find them again easily and also maybe some other people can see it. I don’t know if I can write this every week. However, I’m a huge fan of HighScalability’s “Stuff the internet says on scalability” series. I’d like to do something like that. Since I’m not a master like them, mine will be a lot simpler, less sophisticated of course. I will also try to put some photos that I take on the way of being smartphone photographer :P Write ahead logginghttps://www.sqlite.org/wal.html A cool site:http://foundmagazine.com/ Another addictive game:https://play.google.com/store/apps/details?id=com.ketchapp.stack Google’s cute programming memories: https://bar.foo/ [web.py] CSRF decorator is not complaint with app process...

Solving nodejs error: Cannot find module 'are-we-there-yet'


This happened to me while playing with Web Starter Toolkit (WST)Problemweb_start_kit_hello npm install --global gulp && npm installmodule.js:340 throw err; ^ Error: Cannot find module 'are-we-there-yet' 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> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:2:16) 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)Solution:Go to the global node_modules directory (npm root -g if you don’t know)$ cd /usr/local/lib/node_modulescurl -L https://www.npmjs.com/install.sh | sh

Solving mongodb's user creation problem


I have been test driving mongodb with some serious projects. I have always had difficulty in creating users in any database. Mongodb was no surprise.Here is the working command for me. Error 2016-02-16T01:28:27.570+0000 Error: couldn’t add user: User “[email protected]” already exists at src/mongo/shell/db.js:1004 First add the user: mongo localhost:12346> use admin> db.createUser({ user: "test1", pwd: "test", roles:[ { role: "readWrite", db: "isimibul-dev" }]}) Now connect by using the user:mongo localhost:12346/mydb-dev -u test1 -p testOne side note: If you are having difficulties with connecting to the DB, you can change auth mechanism to MONGODB-CR, this is the old system used back in the days of v2.4; now SHA is used for auth, if you are using an updated version like v3, just use SHA as auth mechanism.

Python regular expression '-' specialness


note to selfUse - instead of - in python regular expressions$ pythonimport rere.search(r’([-\w]*)’, ‘www.hakanu-net’)

Solving Google App Engine users API problem - raise NotAllowedError


Error thrown: <class 'google.appengine.api.users.NotAllowedError'>: Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/ui.py", line 324, in <module> main() File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/ui.py", line 320, in main util.run_bare_wsgi_app(app) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app result = application(env, _start_response) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/ui.py", line 308, in __call__ users.create_login_url(os.getenv('PATH_INFO', '')))]) File "/base/python_runtime/python_lib/versions/1/google/appengine/api/users.py", line 256, in create_login_url raise NotAllowedErrorCode:from google.appengine.api import usersself.redirect(users.create_login_url(self.request.uri))Steps to solve: Go to https://appengine.goog...

Solving mongodb auth problem - pymongo.errors.OperationFailure auth failed


Error thrown:pymongo.errors.OperationFailure: command SON([('authenticate', 1), ('user', u'root'), ('nonce', u''), ('key', u'')]) failed: auth failedSteps to solve: If using global pymongo, update it. sudo pip install pymongo --upgrade If using pymongo from lib folder Fix the version in requirements.txt, as of today, latest version is 3.0.3, you can check it out from here. pymongo==3.0.3 Upgrade the packages: sudo pip install -r requirements.txt -t lib/ --upgrade Redeploy. This will hopefully fix your heroku and Google App Engine deployment with pymongo.


subscribe via RSS