Friday, January 22, 2016

Angular quickstar

Angular quickstart (from CodeSchool) Javascript



app.js:

(function() {
var gem = { name = 'Nick P' };

var app = angular.module('Test', []);
app.controller('StoreController', function() {
this.product = gem;
}
})();
app.html:
<html ng-app="app.js">
<body>
<div ng-controller="StoreController as store">
Product Name: {{store.product.name}}
(Should display "Nick")
</div>
</body>
</html>

"store" is just a locally scoped alias to the StoreController object. It is not available (neither is StoreController) outside the "scope" of the html block in which it is assigned by ng-controller (In this case a div).

My guess is that we want tight scoping on these blocks because interpolating the DOM slows down the page during loading, so we want as little interpolation as possible.

Thursday, January 7, 2016

Yum explodes when libcurl recompiled

Problem:
I've recompiled libcurl and now yum explodes in the following way:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in 
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 254, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 109, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 357, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 651, in doCommand
    return base.search(extcmds)
  File "/usr/share/yum-cli/cli.py", line 881, in search
    for (po, keys, matched_value) in matching:
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 2118, in searchGenerator
    for sack in self.pkgSack.sacks.values():
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 774, in 
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 564, in _getSacks
    self.repos.populateSack(which=repos)
  File "/usr/lib/python2.6/site-packages/yum/repos.py", line 250, in populateSack
    self.doSetup()
  File "/usr/lib/python2.6/site-packages/yum/repos.py", line 83, in doSetup
    self.ayum.plugins.run('postreposetup')
  File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 179, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/fastestmirror.py", line 186, in postreposetup_hook
    if downgrade_ftp and _len_non_ftp(repo.urls) == 1:
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 679, in 
    urls = property(fget=lambda self: self._geturls(),
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 676, in _geturls
    self._baseurlSetup()
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 630, in _baseurlSetup
    mirrorurls.extend(self._getMirrorList())
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1668, in _getMirrorList
    fo = urlgrabber.grabber.urlopen(url, **ugopts)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 628, in urlopen
    return default_grabber.urlopen(url, **kwargs)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 926, in urlopen
    return self._retry(opts, retryfunc, url)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 886, in _retry
    r = apply(func, (opts,) + args, {})
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 925, in retryfunc
    return PyCurlFileObject(url, filename=None, opts=opts)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1066, in _init__
    self._do_open()
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1353, in _ do_open
    self._set_opts()
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1196, in _ set_opts
    self.curl_obj.setopt(pycurl.SSL_VERIFYHOST, opts.ssl_verify_host)
pycurl.error: (43, '')

Solution:

The easiest solution is to disable the SSLVerify option in the yum conf.


  1. edit /etc/yum.conf , (or /etc/yum/yum.conf  depending on your version)
  2. Look for a line under [main] reading sslverify=1
    1. If it exists, change the value to 0
    2. If it doesn't exist, add sslverify=0 to the main block
  3. Viola! your yum should be fixed now

MySQL CSV Export

SELECT <fieldset>
INTO OUTFILE '<output-filename>'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM ....