THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
| # = Kernel#switch | |
| # Provides alternative switch-case syntax. | |
| # | |
| # # support methods: | |
| # value = [] | |
| # switch value do | |
| # on empty?: -> { "none" } | |
| # on one?: -> { "one" } | |
| # on many?: -> { "many" } | |
| # end |
| # Install Git needed for Git based gems | |
| packages: | |
| yum: | |
| git: [] | |
| #!/bin/bash | |
| version=1.0.1 | |
| versionDate="2014-02-14" | |
| function showHelp() { | |
| echo "watchfile - monitor file(s)/command and perform action when changed | |
| Possible ways of usage | |
| ---------------------------------------- |
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
I'm a big fan of Pomodoro time management technique, created by Francesco Cirillo in the 80's. In this post I'll describe what it is, how I use it (tools and their tweaks), and how it helps me to get through my day.
| [].forEach.call( document.querySelectorAll(sel), function(el) { | |
| }); | |
| NodeList.prototype.forEach = Array.prototype.forEach; | |
| NodeList.prototype.forEach = HTMLCollection.prototype.forEach = Array.prototype.forEach; | |
| NodeList.prototype.forEach = HTMLCollection.prototype.forEach = Array.prototype.forEach; | |
| NodeList.prototype.map = HTMLCollection.prototype.map = Array.prototype.map; | |
| NodeList.prototype.filter = HTMLCollection.prototype.filter = Array.prototype.filter; |
| set langmap=ёйцукенгшщзхъфывапролджэячсмитьбюЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;`qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.~QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<> | |
| nmap Ж : | |
| " yank | |
| nmap Н Y | |
| nmap з p | |
| nmap ф a | |
| nmap щ o | |
| nmap г u | |
| nmap З P |
| module BacktickAttributeSyntax | |
| extend self | |
| # WARNING: this is a dangerous hack. Don't use it. It'll bite you if you ever | |
| # accidentally call backticks outside of a model. | |
| # Override backtick syntax to return an Arel attribute for use with | |
| # predications like `.gteq` in the model. To use the original shell | |
| # behaviour, (which should be very uncommon in ActiveRecord models), you can |
| def fib(n)a,b,s=0,1,[];n.times{s<<a;a,b=b,a+b};s end | |
| p fib(33) | |
| [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...] |
I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.
Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.
A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.
This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri