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
/** | |
* Generates all possible unique pairs of elements from the input list. | |
* @param items Input list of elements | |
* @return Pairs containing all possible combinations | |
* @throws IllegalArgumentException if the input list is null | |
*/ | |
fun <T> combs(items: List<T>): List<Pair<T, T>> { | |
require(items.isNotEmpty()) { "Input list cannot be empty" } | |
return items.flatMapIndexed { index, item -> |
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
//https://results.eci.gov.in/ | |
//https://results.eci.gov.in/AcResultGenDecNew2023/partywiseleadresult-742S29.htm | |
//Navigating to the candidate list, open developer tools window, adn paste the following snippet in Console | |
jQuery(".custom-table table tbody tr").map(function (params) { | |
return { | |
"Constituency": jQuery("td:nth-child(2)", this).text(), | |
"Name": jQuery("td:nth-child(3)", this).text(), | |
"Margin": Number(jQuery("td:nth-child(5)", this).text()) |
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 datetime | |
dt = datetime.datetime(2018, 1, 22) | |
end = datetime.datetime(2018, 12, 31) | |
step = datetime.timedelta(days=14) | |
result = [] | |
while dt < end: | |
result.append(dt.strftime('%d-%b-%Y')) |
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
arr = [ | |
['k','l','n','m','d'], | |
['x','m','b','c','d'], | |
['r','a','r','y','x'], | |
['y','i','o','o','d'], | |
['m','s','g','p','t'] | |
] | |
arrLen = len(arr) | |
s = "maryis" |
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
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo | |
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo | |
sudo yum install -y apache-maven | |
mvn --version |
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 com.test | |
import scala.io.Source | |
object meanVarianceFromYahooData { | |
val root = "/" | |
def readData(f: String): List[Double] = { | |
val iter = Source.fromFile(root + f + "csv").getLines().drop(1).map(_.split(",")) | |
def getClose: List[Double] = (iter map (_.last.toDouble)) toList |
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
get.quotes.2011 <- function(symbol){ | |
get.hist.quote(instrument=symbol, start="2011-01-01", | |
end="2011-12-31", quote="AdjClose", provider="yahoo", | |
origin="1970-01-01", compression="d", retclass="zoo") | |
} | |
spy <- get.quotes.2011('spy') |
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 java.util.Calendar; | |
import java.util.Date; | |
public class StartEndWeek { | |
private Calendar cal; | |
private int weekStart; | |
public StartEndWeek(Date date, int weekStart) { | |
this.weekStart = weekStart; | |
this.cal = Calendar.getInstance(); |
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
result = function(){ | |
var a = function(v){ return v.parentNode.nextSibling.nextSibling.nextSibling.nextSibling.textContent} | |
arr = $("b:contains('Total Score')").map(function(k,v){return a(v)}) | |
scores = $.map(arr, function(n, i){ | |
strs = n.split(" / ") | |
return {score:Number(strs[0]),max:Number(strs[1])} | |
}); | |
mt = 0;st = 0;$.each(scores, function(i,n){mt += n.max;st += n.score}) | |
return "Max Points: " + mt + ", Correct: " + st + ", Overall Score: " + (st/mt*100.0).toFixed(2) + " %"}() |
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
save(dt, file="file.RData") | |
load("file.RData") | |
[source](http://r.789695.n4.nabble.com/How-to-create-a-permanent-dataset-in-R-td924692.html) |
NewerOlder