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 misc; | |
import java.util.Comparator; | |
import java.util.Map; | |
import java.util.TreeMap; | |
public class ArrayTools | |
{ | |
private static class ValueComparator<K , V extends Comparable<V>> implements Comparator<K> | |
{ |
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
pub fn sub_string(model: &String, begin: usize, len: usize) -> Option<String> | |
{ | |
let mut to_return = String::with_capacity(len); | |
let mut end = begin + len; | |
if begin > model.len(){ | |
return None; | |
} | |
if begin + len > model.len(){ | |
end = model.len() - begin; |
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
let my_vector = Vec<i32>::new(); | |
for it in my_vector{ | |
it.a = 100; // error: error: use of moved value: `to_return` | |
} |
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
> Origin | |
[,1] [,2] [,3] [,4] | |
[1,] 52 30 49 28 | |
[2,] 30 50 8 44 | |
[3,] 49 8 46 16 | |
[4,] 28 44 16 22 | |
> round(X,5) | |
[,1] [,2] [,3] [,4] | |
[1,] 265.2557 0.0000 0.00000 0.00000 | |
[2,] 0.0000 104.8846 0.00000 0.00000 |
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 numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import os | |
def computeCost(X, y, theta): | |
inner = np.power(((X * theta.T) - y), 2) | |
return np.sum(inner) / (2 * len(X)) | |
def gradientDescent(X, y, theta, alpha, iters): |
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
# example from http://www.johnwittenauer.net/machine-learning-exercises-in-python-part-1/ | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import os, sys | |
def computeCost(X, y, theta): | |
inner = np.power(((X * theta.T) - y), 2) | |
return np.sum(inner) / (2 * len(X)) |
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
<syntaxhighlight lang="python"> | |
</syntaxhighlight> |
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
#! /bin/sh | |
# You have to be at the root of the package of the project from which you | |
# want to install the rpm | |
projectName=api_intranet | |
projectNameLong=intranet-parcel-defect-process | |
target="ftops-recette-apiserverintranet-a-01.archinext.local" | |
# Create rpm | |
cat version.sbt | tr - _ > temp && mv temp version.sbt |
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
// from : http://jonasboner.com/real-world-scala-dependency-injection-di/ | |
case class User(name: String) | |
trait UserRepositoryComponent { | |
val userRepository: UserRepository | |
trait UserRepository { | |
def authenticate(username: String, password: String): User | |
def create(user: User): Unit | |
def delete(user: User): Unit |
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
case class Query[D <: Database, +A](db: D, ec: ExecutionContext)(private val atomic: Connection => A) extends Logger { | |
def map[B](f: A => B): Query[D, B] = | |
Query(db, ec)(f compose atomic) | |
def flatMap[B](f: A => Query[D, B]): Query[D, B] = | |
Query(db, ec)(connection => f(atomic(connection)).atomic(connection)) | |
def zip[B](query: Query[D, B]): Query[D, (A, B)] = | |
flatMap { a => |
OlderNewer