Skip to content

Instantly share code, notes, and snippets.

View fbiville's full-sized avatar

Florent Biville fbiville

View GitHub Profile
fibonacci :: (Ord a, Num a) => a -> [a]
fibonacci limit = _fibonacci limit [1,2]
_fibonacci :: (Ord a, Num a) => a -> [a] -> [a]
_fibonacci limit x
| sum < limit = _fibonacci limit (x++[sum])
| otherwise = x
where x1x2 = drop ((length x)-2) x
sum = ((head x1x2)+(last x1x2))
foldl (+) 0 (filter (\n -> n `mod` 3 == 0 || n `mod` 5 == 0) [1..999])
@fbiville
fbiville / foobarqix.hs
Last active August 29, 2015 14:05
My second "real" Haskell program
foobarqix n = take n [ _substitute x | x <- [1..] ]
_substitute value = __substitute value "" [(3,"Foo"),(5,"Bar"),(7,"Qix")]
__substitute value "" [] = show value
__substitute value replacement [] = replacement
__substitute value replacement multiples =
let multiple = fst (head multiples)
string = snd (head multiples)
rest = tail multiples in
@fbiville
fbiville / Balance.scala
Last active August 29, 2015 14:00
ScalaNoob - ProgFun Week1
def balance(chars: List[Char]): Boolean = {
val result:(Boolean, Int) = chars.foldLeft((true, 0))((tuple:(Boolean, Int), char:Char) => {
val count = balanceCount(tuple._2, char)
(tuple._1 && count >= 0, count)
})
result._1 && result._2 == 0
}
private def balanceCount(previousCount: Int, char: Char) : Int = {
char match {
@fbiville
fbiville / DOC_version_is.md
Last active August 29, 2015 14:00
version_is : quick Git-managed Maven version checker

version_is

Pitch

version_is detects whether the current dir POM (or the whole Git project POM files) match the specified version.

This can be useful as a sanity check after a merge (where POM versions could have silently changed to a non-desired value).

Setup

@fbiville
fbiville / VIDAL-WinterChallenge2014-GraphGist.adoc
Last active December 3, 2015 14:14
VIDAL contribution to Neo4j GraphGist Winter Challenge 2013-2014!

DoctorFinder!

This GraphGist represents a mobile application backend helping users to find adequate drugs and specialists given their physical characteristics, location and current symptoms.

Our resulting model

@fbiville
fbiville / beginner.clj
Created January 11, 2014 13:37
Can you guess what it does? (Improvement suggestions are welcome ofc)
(fn mysteryFunction [s]
((fn append [mySeq acc]
(let [beginning (butlast mySeq)]
(if (= beginning nil)
(conj acc (first mySeq))
(append beginning (conj acc (last mySeq)))
)
)
) s [])
)
@fbiville
fbiville / aggregator.js
Created January 4, 2014 10:07
Custom feed aggregator. Stack: requirejs (+text.js)+underscore+async+moment.js+jquery+handlebars
define( ['jquery', 'underscore', 'async', 'moment', 'Handlebars'],
function($, _, async, moment, Handlebars) {
var crossOriginFeedParserUrl = function(limit, feedUrl) {
return document.location.protocol +
'//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+
limit+
'&callback=?&q=' +
encodeURIComponent(feedUrl);
},
@fbiville
fbiville / Vidal.cypher
Last active December 31, 2015 13:29
VIDAL GraphGist
CREATE (p:PATIENT {firstName:"Robert", lastName:"Patraque"}) RETURN p;
CREATE (p:PATIENT {firstName:"Chantale", lastName:"Tristoune"}) RETURN p;
CREATE (s:SYMPTOM {name:"Écoulement nasal"}) RETURN s;
CREATE (s:SYMPTOM {name:"Fièvre"}) RETURN s;
CREATE (s:SYMPTOM {name:"Éructations"}) RETURN s;
CREATE (s:SYMPTOM {name:"Flatulences"}) RETURN s;
CREATE (s:SYMPTOM {name:"Vomissement"}) RETURN s;
@fbiville
fbiville / recommendations.cypher
Created October 27, 2013 15:10
Exemple de graphe social professionnel.
Example CREATE (flo:CONTACT {name: 'Florent'}) RETURN flo;
CREATE (eric:CONTACT {name: 'Eric'}) RETURN eric;
CREATE (jb:CONTACT {name: 'Jean-Baptiste'}) RETURN jb;
CREATE (samuel:CONTACT {name: 'Samuel'}) RETURN samuel;
CREATE (meta:COMPANY {name: 'Metaboli'}) RETURN meta;
CREATE (lt:COMPANY {name: 'Lateral Thoughts'}) RETURN lt;
// -- Florent worked for Metaboli
MATCH (flo:CONTACT), (meta:COMPANY)