This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculates a compound interest (procent składany) for a given period of time | |
* with given annual interest rate, number of capitalizations and saving period. | |
* | |
* @param amount | |
* initial investment | |
* | |
* @param interestRate | |
* nominal annual interest rate (in decimal, so if interest rate is 5%, | |
* we give 0.05) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given such a DB structure (MySQL): | |
# | |
# Table: module_cms_articles | |
# | |
# id | version_since | version_until | creation_date | creator_id | title | lead | content | visible | |
# ----+---------------------+---------------------+---------------------+------------+-----------------------+-----------------+--------------------------+--------- | |
# 1 | 2010-05-12 19:57:05 | 2010-05-12 20:15:20 | 2010-05-12 19:57:05 | 1 | 1-st article | Introduction... | First article. | 0 | |
# 1 | 2010-05-12 20:15:20 | 2010-05-12 20:27:28 | 2010-05-12 19:57:05 | 1 | 1-st article | Introduction... | First article. Extended. | 0 | |
# 1 | 2010-05-12 20:27:28 | 2037-12-31 23:59:59 | 2010-05-12 19:57:05 | 1 | 1-st article modified | Introduction... | First Article. Extended. | 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Most recent version of all records and creation date of the oldest version | |
# | |
# "id","version_since","version_until","content" | |
# "1","2010-06-01","2010-06-05","Initial text." | |
# "1","2010-06-05","2010-06-10","Modified text." | |
# "1","2010-06-10","2037-12-31","Final text." | |
# "2","2010-05-01","2010-05-31","Second initial text." | |
# "2","2010-05-31","2010-06-10","Modified second text." | |
# "2","2010-06-10","2010-06-15","Modified again second text." | |
# "2","2010-06-15","2037-12-31","Second final text." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prints to browser console (Chrome, Firefox), no explicit ifs. Starts from 1. | |
for(i=0;i++<100;console.log([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 72 characters | |
// Writes to array 'a', no explicit ifs. Starts from 1. | |
for(a,i=0;i<100;a[i++]=([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 68 characters | |
// Returns an array (Firefox only), no explicit ifs, no explicit loops. Starts from 0. | |
Array.apply([],Array(100)).map((e,i)=>[['fizz'][i%3],['buzz'][i%5]].join('')||i) // 80 characters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples | |
* is 23. | |
* | |
* <p>Find the sum of all the multiples of 3 or 5 below 1000. | |
* | |
* @author Adrian K. <[email protected]> | |
*/ | |
object ProjectEulerProblem001 { | |
def main( args : Array[String] ) : Unit = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a given power of ten (10 ^ 0 = 1, 10 ^ 1 = 10, 10 ^ 2 = 100, etc.). | |
*/ | |
function powerOfTen( power ) { | |
var result = 1; | |
for ( i = 0; i < power; i++ ) { | |
result *= 10; | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <p> | |
* What's the point (if there is any) and logic behind using/non-using "final" keyword for parameters in interface method and/or | |
* its implementation? | |
*/ | |
public class Test { | |
// Example 1: | |
public static interface I { | |
void perform( final Boolean b ); // final on b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically generate Java app classpath based on jars in 'lib' folder | |
javac -cp `echo lib/*jar | tr ' ' :` App.java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.utils.getTimer; | |
import net.flashpunk.*; | |
import net.flashpunk.utils.*; | |
/** | |
* <p> | |
* The reason to use such test is that under Linux holding a key triggers a key-repeat functionality after | |
* a moment and so, key-press events are generated. Therefore the Input.pressed() method will periodically |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
public static function argbDecombine( ARGB:uint ):Array { | |
return [ ARGB >> 24, ( ARGB >> 16 ) & 0xFF, ( ARGB >> 8 ) & 0xFF, ARGB & 0xFF ]; | |
} | |
public static function argbCombine( ARGB:Array ):uint { | |
return argbCombine( ARGB[0], ARGB[1], ARGB[2], ARGB[3] ); | |
} |
OlderNewer