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
// No Optional arguments, hence no Optional return value. | |
Integer product(Integer value1, Integer value2) { | |
return value1.intValue()*value2.intValue(); | |
} | |
// Calling place is same as earlier, but presence check is done | |
// as soon as the values are computed before calling product() | |
// function. | |
Optional<Integer> value1 = computeValue1(); | |
if(!value1.isPresent()) { | |
System.out.println("value1 is missing."); |
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
/** | |
* Computes the product of the given Integer arguments. | |
* If any of the arguments are missing, it will return empty as result. | |
*/ | |
Optional<Integer> product(Optional<Integer> value1, Optional<Integer> value2) { | |
if(value1.isPresent() && value2.isPresent()) { | |
return Optional.of(value1.get().intValue()*value2.get().intValue()); | |
} else { | |
return Optional.empty(); | |
} |
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
#!/usr/bin/env python | |
# | |
# Author: Rosarin Roy rosarinjroy at hotmail dot com | |
# | |
help_text = """ | |
This script can be used similar to "perl -ne". See the examples below. | |
Example 1: Hello world | |
mypy 'print "Hello World"' |
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
# Works only inside xterm or an equivalent term. | |
function wtitle { | |
if [ -z "$ORIG_PS1" ] ; then | |
ORIG_PS1=$PS1 | |
fi | |
export PS1="\[\033]0;$1 - \u@\h:\w\007\]$ORIG_PS1" | |
} |
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
;; This utility is to open a SQLplus session from an intermediate jump host. | |
;; You can invoke the "open-remote-sqlplus-session-interactive" function interactively, | |
;; which will prompt you for a jump host and the connection string to the SQLplus session. | |
;; Please change the "list-of-sqlplus-setup-commands" to fit your needs. | |
;; Also you should change the entries in alias-to-jumphosts-alist to a suitable value. | |
;; - Roy 09/15/2012. | |
(defvar alias-to-jumphosts-alist '(("development" . ((:sshurl . "user@devhost") (:sqlurl . "devuser/devpassword@devel"))) | |
("integration" . ((:sshurl . "user@integhost") (:sqlurl . "intuser/intpassword@integ"))) | |
("qa" . ((:sshurl . "user@qahost") (:sqlurl . "qauser/qapassword@qa")))) |
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
(defun rails-console () | |
"Create a rails console process, if one doesn't exist. And switch to *rails-console* buffer." | |
(interactive) | |
(if (null (get-buffer "*rails-console*")) | |
(progn | |
(term "/bin/bash") | |
(term-send-string (get-buffer-process "*terminal*") "rails console\n") | |
(switch-to-buffer "*terminal*") | |
(rename-buffer "*rails-console*") | |
(term-line-mode)) |
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
10000000, 19366534, 58864372, 3.04 | |
20000000, 29383997, 95479759, 3.25 | |
30000000, 45976039, 175275721, 3.81 | |
40000000, 57853499, 234138642, 4.05 | |
50000000, 73506767, 291500083, 3.97 | |
60000000, 87584072, 349426518, 3.99 | |
70000000, 103897341, 429060055, 4.13 | |
80000000, 122580223, 526850899, 4.30 | |
90000000, 130561644, 563535489, 4.32 | |
100000000, 149137528, 640108388, 4.29 |
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
package main; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
/** | |
* The objective is to compute the value of long represented as a sequence of | |
* bytes using ByteBuffer and by shifting, and compare the performance. | |
* | |
*/ |