Skip to content

Instantly share code, notes, and snippets.

💭
Compiling

julien Lengrand-Lambert jlengrand

💭
Compiling
Block or report user

Report or block jlengrand

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jlengrand
jlengrand / java-jpackage-versions.sh
Created Apr 3, 2020
Checking java and jpackage versions in terminal
View java-jpackage-versions.sh
$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment AdoptOpenJDK (build 14+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14+36, mixed mode, sharing)
$ jpackage
WARNING: Using incubator modules: jdk.incubator.jpackage
Usage: jpackage <options>
Use jpackage --help (or -h) for a list of possible options
View queryBatmanByRating.kotlin
println("Ratings query took : ${measureTimeMillis() {
transaction(db) {
var result = (Titles innerJoin Ratings).slice(Titles.primaryTitle, Titles.titleType, Ratings.averageRating, Ratings.numVotes).select {
((Titles.primaryTitle like "%batman%") and (Titles.titleType like "movie")
and Titles.tconst.eq(Ratings.tconst))
}.orderBy(Ratings.averageRating)
.toList()
println(result.size)
println(result)
View referenceTitleAndRating
val tconst: Column<String> = (varchar("tconst", 10) references Ratings.tconst).uniqueIndex()
View titlesandratings.kotlin
object Ratings : IntIdTable(){
val tconst : Column<String> = varchar("tconst", 10).uniqueIndex()
val averageRating : Column<Float?> = float("averageRating").nullable()
val numVotes : Column<Int?> = integer("numVotes").nullable()
}
object Titles : IntIdTable() {
val tconst : Column<String> = varchar("tconst", 10).uniqueIndex()
val titleType: Column<String> = varchar("titleType", 50) // TODO: Own Table?
val primaryTitle: Column<String> = varchar("primaryTitle", 500)
@jlengrand
jlengrand / transaction.kotlin
Last active Mar 19, 2020
Transcations split in Exposed
View transaction.kotlin
private fun loadData(db : Database, table: Table, fileName: String, partitions: Int, operation: BatchInsertStatement.(String) -> Unit){
val reader = File(fileName).bufferedReader()
reader.readLine() // pass headers
val lines = reader.readLines()
val partitionSize = lines.size / partitions
val listOfLists = lines.chunked(partitionSize)
var increment = 0
View service-worker.js
"use strict";
var precacheConfig = [
["/index.html", "6633bcbb6d392a7d68be37924b341845"],
["/static/js/main.f95e1c59.chunk.js", "559581975d6026fccabb204f217e44db"],
["/static/js/runtime~main.1b922744.js", "13a6cba6703084ad6f60a3db941db615"],
["/static/js/vendors~main.3ca81432.chunk.js", "86fba34edc08a61c670b6c7527e6b813"]
],
cacheName = "sw-precache-v3-sw-precache-webpack-plugin-" + (self.registration ? self.registration.scope : ""),
ignoreUrlParametersMatching = [/^utm_/],
addDirectoryIndex = function(e, n) {
@jlengrand
jlengrand / spotiProxy
Created Apr 22, 2018
Activating / Deactivating Spotify proxy settings
View spotiProxy
#!/bin/sh
ON_OFF=$1
SPOTIFY_PREFS="$HOME/Library/Application Support/Spotify/prefs"
PROXY_ON="network.proxy.mode=2" #HTTP Proxy
PROXY_OFF="network.proxy.mode=1" #No proxy
if [ ! -f "$SPOTIFY_PREFS" ]; then
echo "Spotify preference file not found. Exiting"
exit 1
View extract
#!/bin/bash
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar xvJf $1 ;;
*.bz2) bunzip2 $1 ;;
View keybase.md

Keybase proof

I hereby claim:

  • I am jlengrand on github.
  • I am jlengrand (https://keybase.io/jlengrand) on keybase.
  • I have a public key ASBOPLSHLfuup2FQb9eaoKIljG0q1LIqAesn4cYTaeiJQwo

To claim this, I am signing this object:

@jlengrand
jlengrand / octocat.py
Created May 10, 2014
Get the latest octocat
View octocat.py
from bs4 import BeautifulSoup
import urllib2
url = "http://feeds.feedburner.com/Octocats"
content = urllib2.urlopen(url).read()
soup = BeautifulSoup(content)
print soup.find("img")["src"]
You can’t perform that action at this time.