?

Log in

Shlomif's Technical Posts Community [entries|archive|friends|userinfo]
Shlomif's Technical Posts Community

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Shlomi Fish's Homepage Main Journal Homesite Blog Planet Linux-IL Amir Aharoni in Unicode open dot dot dot ]

Cython: Report and Tips [Jun. 4th, 2017|02:41 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Music |unreal_dm - Reach out]

Cython allows one to compile code written using a superset of the Python programming language into C code for improved performance. I recently tried it in an attempt to speed up my solution to a Project Euler problem, which was ran slowly, even by pypy. After some amount of work, the cython-based solution outperformed the pure-Python code, without me having to reimplement it all in C or C++ or similar. So you too should consider using it, if you need the extra performance.

The rest of this post contains some Cython tips for using it well that I discovered in my (so far relatively limited) experimentation with it.

  1. I noticed that cdef int i; for in xrange(0, mymax) does not get optimised while cdef int i; for i in range(mymax); does.

  2. cdef int arr[100][100] declares a local array of 100*100 elements , and keeps copying it, which is likely not what you want. On the other hand, cdef int [100] * ptr generates a pointer.

  3. “cdef” cannot be used inside loops.

  4. It is a good idea to declare the C types as late as possible - only right before the time-critical code when you absolutely need to use them. One can initialize them from dynamically-typed python data structures.

  5. One can copy+paste the compiler's invocation command on the command line and edit it to apply better optimisation flags. There may be a way to customise the compilation command by editing the “setup.py” file, but I didn't bother to figure it out yet.

  6. One can and should inspect the generated .c file to see the resultant C code to see if anything is done sub-optimally.

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Why E-mail is not only a Todo list [Apr. 7th, 2017|02:58 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Amir Gelman vs. Bertycox - The Signal]

This is a essay that aims to be a correction to what Paul Graham wrote:

Email was not designed to be used the way we use it now. Email is not a messaging protocol. It's a todo list. Or rather, my inbox is a todo list, and email is the way things get onto it. But it is a disastrously bad todo list.

I'm open to different types of solutions to this problem, but I suspect that tweaking the inbox is not enough, and that email has to be replaced with a new protocol. This new protocol should be a todo list protocol, not a messaging protocol, although there is a degenerate case where what someone wants you to do is: read the following text.

While it seemed to have made a little sense at first, I eventually realised that there are other resources whose functionality I use as a to-do list aside from email. For example:

  1. My browser's bookmarks’ menu where I bookmark links to deal with.

  2. My home directory and other directories on my file system where I put non-permanent files.

  3. Non-committed files in version control repositories.

  4. Bug trackers / issue trackers.

  5. Actual to-do lists I keep and manage.

However, there are other aspects for their use aside from serving as a to-do list, and they are all different from one another.

As a result, while trying to create an alternative to E-mail is commendable, I suspect that trying to replace E-mail with a to-do-list-like protocol will not prove to be popular, because like those - E-mail is not exclusively a to-do list.

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution-Non commercial 4.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Saving hard disk space on Amazon AWS Linux Instances [Feb. 22nd, 2017|10:44 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |productive]
[Current Music |One Thing cover by Cimorelli]

By default, AWS' EC2 machines are given a hard disk of only 8 GB of space, and each extra gigabyte costs extra, even if you rent a machine with much more RAM than that. Some options you can try if you don't want to enlarge the hard disk are:

  1. Remove unnecessary system packages (using the “apt remove” command on Ubuntu/Debian VMs or equivalents. From my experience, the default Ubuntu VMs ship with a lot of junk preinstalled.

  2. Remove packages that you installed and no longer need (e.g: gcc).

  3. One can also try to do “rm -fr /usr/share/man /usr/share/doc” and other unnecessary directories that are cheaper to use on local VMs or host systems.

  4. Consider using S3 or similar instead of the local hard disk, which should be much cheaper.

Good luck!

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: How to Make Pidgin’s Incoming Messages Icon Animated [Dec. 15th, 2016|01:45 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Harry Belafonte - Banana Boat Song (Day-O)]

Pidgin is an open source chat client. If you want to make its incoming messages system tray icon animated, simply right click on the icon, and select “Blink on new messages”. This way it will be harder to miss and that is what I was used to having.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Nullifying/Resetting/Overriding a Remote Git Repository's Branch History [Jul. 16th, 2016|07:46 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Music |Nethis - Gimin]

If you have a branch in a remote repository of the Git version control system which you need to reset/nullify/override its history, you can do it by setting up a brand new branch with the same name (say starting in an empty repository) and then pushing it from there to the remote while specifying the --force flag. Thanks to the people from #git on Freenode for enlightening me.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Disabling the Touchpad/Trackpad on Linux [Jul. 6th, 2016|04:54 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |productive]
[Current Music |Len - Steal My Sunshine]

If your touchpad/trackpad (= the built-in mouse control found in some laptops) is a Synaptic one, then you can disable it on Linux systems by issuing the command synclient TouchpadOff=1 (you may need to install synclient first. I originally learned of it from this link on kde-apps.org.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Checking the Latest Build in Travis CI [May. 27th, 2016|03:43 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |lazylazy]
[Current Music |Shania Twain - You win my love]

If you are using Travis CI, you can check the latest build after a failed build by going to the “Build History” tab in your project’s main page (= https://travis-ci.org/shlomif/fc-solve or equivalent), and selecting the new commit.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Speed up building perl 5 by not installing the man pages [Dec. 3rd, 2015|06:37 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , , ]
[Current Location |Home]
[Current Mood |accomplished]
[Current Music |David Amber ft. Devyn Rush - Gnarly (from jamendo.com)]

2015-12-03: Tech Tip: Speed up building perl 5 by not installing the man pages

When building perl 5 from source, one can speed up the "make" and "make install" stages significantly by not installing the man pages. To do so, pass the options “-Dman1dir=none -Dman3dir=none” to “sh Configure”.

Cheers, and happy upcoming Chanukkah, and happy Christmas and/or Yulth or whatever winter holiday you celebrate.

Call for action

Creative Commons has set up a campaign to stop TPP - the Trans-Pacific Partnership. Please consider signing it and spreading the word.

Licence

Copyright by Shlomi Fish, 2015.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

Link1 comment|Leave a comment

Tech Tip: Make Panes Equally Heighted in Tmux [Nov. 6th, 2015|12:19 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Cascada - Summer of Love]

When pressing «Ctrl+B;"» in tmux to split a pane vertically there, one will notice that tmux splits the existing pane into two which can result in smaller and smaller panes. In order to fix this, one can type «Ctrl+B;M-2» (where “M” is the Meta key and is normally “Alt” on most keyboards.) which will make all the panes equally heighted.

I found this feature after wondering whether it existed, and then searching for it in the tmux man page.

Licence

Copyright by Shlomi Fish, 2015.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Locally Host the Firefox’s Personas Favourites File [Sep. 15th, 2015|03:18 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , , , ]
[Current Location |Home]
[Current Mood |calmcalm]
[Current Music |Manowar - I believe]

A constant annoyance when trying to use the Firefox extension “Personas Rotator” was that downloading the favourites file from the Firefox addons site failed, which made it stop rotating. I recently found a solution for that which I'd like to share.

First of all, login to the Mozilla addons site and access and bookmark the JSON data file’s URL. Save it to a file and host it using a local HTTP service (such as Apache, the one line Python HTTP service command line, or sthttpd’s “thttpd -p $PORT” invocation).

Then, go to Firefox’s “about:config”, access the “extensions.personas.favorites-feed.url” key and change it to the locally served one. It should work fine after restarting Firefox, and one upside to it would be that you no longer need to be logged in to addons.mozilla.org for it to work.

Remember to save the file again every once-in-a-while, after you have added new favourites. A final note is that a “file://” URL may work fine as well, but I have not tried it yet.

Happy rotating, and Shanah Tovah if appropriate!

Licence

Copyright by Shlomi Fish, 2015.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]