I hereby claim:
- I am bondarewicz on github.
- I am bondarewicz (https://keybase.io/bondarewicz) on keybase.
- I have a public key ASBexiynXvVUuVgIhEjgNngIk-Cf5pb7D5Tb2_2Z_qBgbQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| //http://en.wikipedia.org/wiki/Price_elasticity_of_demand | |
| //In general, the demand for a good is said to be inelastic (or relatively inelastic) when the PED is less than one (in absolute value): | |
| //that is, changes in price have a relatively small effect on the quantity of the good demanded. | |
| //The demand for a good is said to be elastic (or relatively elastic) when its PED is greater than one (in absolute value): | |
| //that is, changes in price have a relatively large effect on the quantity of a good demanded. | |
| //Revenue is maximized when price is set so that the PED is exactly one. |
| <?php | |
| //http://refectoryofajumblesale.wordpress.com/2013/06/04/currying-php/ | |
| $add = function($a, $b, $c) { | |
| return $a + $b + $c; | |
| }; | |
| $add2 = curry($add, 2); | |
| echo $add2(4, 5); |
| <?php | |
| function whats_largest($arr, $idx) | |
| { | |
| sort($arr, SORT_NUMERIC); | |
| return($arr[count($arr) - intval($idx)]); | |
| } | |
| $array = array(); |
| 1. open drive utility and create new image using 'sparse bundle disk image' and save to desktop | |
| 2. unmount and copy to network drive destination (using terminal's go->connect to server) | |
| 3. delete the image from desktop and open copied image on network drive unsing drive utility, mount | |
| 4. open terminal and paste "defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1 && killall Finder" | |
| 5. then "sudo tmutil setdestination /Volumes/[YOUR_DRIVE_NAME_HERE]" | |
| https://www.youtube.com/watch?v=_VwHGSHSnDk |
| <?php | |
| ######################################################### | |
| # 0-1 Knapsack Problem Solve with memoization optimize and index returns | |
| # $w = weight of item | |
| # $v = value of item | |
| # $i = index | |
| # $aW = Available Weight | |
| # $m = Memo items array | |
| # PHP Translation from Python, Memoization, |
| <?php | |
| // http://en.wikipedia.org/wiki/Knapsack_problem | |
| // http://upload.wikimedia.org/wikipedia/commons/c/c6/Knapsack_greedy.svg | |
| // KNAPSACK BALANCER! | |
| class Balancer | |
| { | |
| public static function balance($items, $key) | |
| { |
| var arr = [4,5,7,8,14,45,76]; | |
| function even(a){ | |
| return a.filter(function(val){return val%2===0}) | |
| } | |
| alert(even(arr)); |
| function likes(names) { | |
| names[0] = names[0] || "no one"; | |
| if (names.length > 3) names[2] = names.length-2 + " others"; | |
| return names.slice(0,3).join(", ").replace(/(.*), /, "$1 and ") + " like" + (names.length<2 ? "s" : "") + " this"; | |
| } | |
| alert(likes([])); // must return "no one likes this" | |
| alert(likes(['Peter'])); // must return "Peter likes this" | |
| alert(likes(['Jacob', 'Alex'])); // must return "Jacob and Alex like this" |
| select | |
| length(replace(address_str, '\r\n', '\r\n ')) - length(address_str) as AddressLineCount, | |
| substring_index(substring_index(address_str,'\r\n',1),'\r\n',-1) as AddressLine1, | |
| substring_index(substring_index(address_str,'\r\n',2),'\r\n',-1) as AddressLine2, | |
| substring_index(substring_index(address_str,'\r\n',3),'\r\n',-1) as AddressLine3 | |
| from ( | |
| select replace(concat(address,'\r\n'),'\r\n\r\n','\r\n') as address_str | |
| from table_location where location_id = 1 | |
| ) normalized |