Skip to content

Instantly share code, notes, and snippets.

View rbobillot's full-sized avatar

Raphael Bobillot rbobillot

View GitHub Profile
#!/bin/bash
function show_usage {
echo "
This is a small script to change default IntelliJ's desktop binary
"
echo -e " usage: \033[92mbash $0 \033[93mpath/to/idea\033[0m\n"
}
function find_candidates {
#!/bin/bash
# UPDATE PROMPT WITH LAST VERSION
# TO INSTALL:
# Make sure in your ~/.bashrc that:
# - the line '[[ -s ~/.showbranch ]] && source ~/.showbranch' doesn't exist or is commented
#
# Then simply run:
# - curl "https://gist.githubusercontent.com`curl -s https://gist.github.com/rbobillo/710df71012c7d43db95846e83898cba6 | grep '>Raw<' | sed 's/.*href="\([^ ]*\)".*/\1/'`" > ~/.showbranch && echo '[[ -s ~/.showbranch ]] && source ~/.showbranch' >> ~/.bashrc && source ~/.bashrc
#!/bin/bash
if [[ $# == 1 ]]
then
if [[ -f $1 ]]
then
TEMPLATE_b64='IyEvYmluL3NoCgpNWVNFTEY9YHdoaWNoICIkMCIgMj4vZGV2L251bGxgClsgJD8gLWd0IDAgLWEgLWYgIiQwIiBdICYmIE1ZU0VMRj0iLi8kMCIKamF2YT1qYXZhCmlmIHRlc3QgLW4gIiRKQVZBX0hPTUUiOyB0aGVuCiAgICBqYXZhPSIkSkFWQV9IT01FL2Jpbi9qYXZhIgpmaQpleGVjICIkamF2YSIgJGphdmFfYXJncyAtamFyICRNWVNFTEYgIiRAIgoK'
jar_file=$1
exec_file=$(basename `echo $jar_file | rev | cut -d '.' -f2 | rev`)
trait Infos {
val validActions = 'r' :: 'l' :: 'a' :: Nil
val dirs = Map(0 -> "North", 1 -> "East", 2 -> "South", 3 -> "West")
def isAction: Char => Boolean = validActions contains _
implicit class StringCheck(str: String) {
def isActionString: Boolean = str forall isAction
def isNaAS: Boolean = !isActionString
def isNumber: Boolean = str forall (x => ('0' to '9') :+ '-' contains x)
object Test {
type R = BigInt
def main(av:Array[String]):Unit = {
//timed{ pascal(0, av.head.toInt) }
timed{ pascalV2(av.head.toInt) }
}
import collection.parallel.mutable.{ParArray => Array}
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.InputStream
import java.io.BufferedInputStream
import java.io.BufferedOutputStream
trait GlobalInfos {
val plainName = "plainImage"
val cryptName = "cryptImage"
val flickrLink = "https://www.flickr.com/explore"
object Scramble {
val moves = Array("Up", "Down", "Left", "Right", "Front", "Back").map(_.head)
val orien = Array("2" -> 1, "'" -> 2, "" -> 3).flatMap{case (rot, weight) => 1 to weight map (_ => rot)}
val rands = orien.flatMap(x => moves.map(_ + x))
def isNum(num:String) = num forall ('0' to '9' contains _)
def getRandElemFromArray[T](arr:Array[T]) = arr( util.Random.nextInt(arr.size) )
def generate(size:Int) = 1 to size map (_ => getRandElemFromArray(rands)) mkString " "
def scramble(size:String) = if (false == isNum(size)) "Cannot Scramble" else generate(size.toInt)
@rbobillot
rbobillot / rootMe_suite_artithmetique.scala
Last active March 3, 2016 09:40
root-me.org - Programmation/ch1 - Suite arithmétique - solution
#!/usr/bin/env scala
import io.Source, java.net.{URL,URLConnection}, collection.mutable.Map
def compute[I<:Int](start:I, end:I, alpha:I, beta:I): BigInt =
(1 to end).foldLeft(BigInt(start)){ (acc,x) => acc + alpha + beta*(x-1) }
val enigmaUrl = "http://challenge01.root-me.org/programmation/ch1"
val answerUrl = enigmaUrl + "/ep1_v.php?result="
val headerMap = Map("Cookie" -> "")
def qsort : Seq[Int] => Seq[Int] =
a => (a.size < 2) match {
case true => a
case false =>
val pivot = a(a.size / 2)
qsort (
a filter (pivot > _)) ++
(a filter (pivot == _)) ++
qsort (a filter (pivot < _)
)
#!/bin/sh
if [[ $UID != 0 ]] ; then
printf "\033[91mPlease run this script as \033[96mSuper User\033[0m\n"
exit
fi
cd /Volumes/
printf "\033[92m"
PS3="Please enter your drive's number: "