This file contains 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
import play.api._ | |
import play.api.mvc._ | |
object Global extends GlobalSettings { | |
override def onHandlerNotFound(request: RequestHeader): Result = { | |
// handle trailing slashes | |
if (request.path.endsWith("/")) { | |
// construct a new URI without the slash |
This file contains 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
val lnOf2 = scala.math.log(2) // natural log of 2 | |
def log2(x: Double): Double = scala.math.log(x) / lnOf2 |
This file contains 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
val newID = Inventory.save(data) | |
Redirect( | |
controllers.routes.Inventory.index.toString + | |
"#record_%d".format(newID) | |
).flashing("success" -> "Insertion succeeded!") |
This file contains 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
using System.Threading.Tasks; | |
static void SleepThenPrintSquare(int n) { | |
Thread.Sleep(2000); | |
Console.WriteLine("{0}", n * n); | |
} | |
static void Main() { | |
var tasks = new List<Task>(5); |
This file contains 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
using System.Threading.Tasks; | |
static void SleepThenPrintSquare(int n) { | |
Thread.Sleep(2000); | |
Console.WriteLine("{0}", n * n); | |
} | |
static void Main() { | |
var tasks = new List<Task>(5); |
This file contains 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
void MergeList(ref List<int> list1, List<int> list2) | |
{ | |
int list1Size = list1.Count; | |
int list2Size = list2.Count; | |
int totalSize = list1Size + list2Size; | |
list1.Capacity = totalSize; | |
int index1 = 0; | |
int index2 = 0; |
This file contains 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
void MergeListImproved(ref List<int> list1, List<int> list2) | |
{ | |
int list1Size = list1.Count; | |
int list2Size = list2.Count; | |
int totalSize = list1Size + list2Size; | |
var newList = new List<int>(totalSize); | |
int index1 = 0; | |
int index2 = 0; |
This file contains 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
Robot r = new Robot(); | |
System.out.println("Start!"); | |
Thread.sleep(2000); // give yourself some margin to switch window | |
int[] times = { 1, 5, 4, 4, 1, 3, 2 }; // number of shots for each distance | |
int[] delays = { 400, 400, 575, 820, 850, 1150, 1350 }; // time holding the ball | |
int[] delays2 = { 200, 650, 700, 600, 400, 450, 400 }; // time waiting for a new ball | |
for (int i = 0; i < times.length; i++) | |
for (int j = 0; j < times[i]; j++) { | |
r.keyPress(KeyEvent.VK_SPACE); | |
r.delay(delays[i]); |
This file contains 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
shawty({ | |
'success': 1, | |
'message': '', | |
'short': 'http://luu.bz/bD', | |
'long': 'http://en.wikipedia.org/wiki/URL_shortening', | |
'hits': 0, | |
'timestamp': 1349564105 | |
}); |
This file contains 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
<script> | |
function shawty(data) { | |
if (data.success) { | |
document.write( | |
'<a href="' + data.short + | |
'">Short URL to the current page</a>'); | |
} | |
} | |
</script> | |
<script src="//luu.bz/shawty.js"></script> |
OlderNewer