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.boot; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | |
@SpringBootApplication(exclude = ThymeleafAutoConfiguration.class) | |
public class BootApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(AppSecurityApplication.class, args); |
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 scala.util.{Success, Failure} | |
val seq=Seq(Success(1), Failure(new Exception("bang")), Success(2)) | |
// all emit List(1, 2) | |
seq.map(_.toOption).flatten | |
seq.flatMap(_.toOption) | |
seq.filter(_.isSuccess).map(_.get) | |
seq.collect{case Success(x) => 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
the 'repackage' command creates a distributable box file from the unpacked box in your ~/.vagrant.d/boxes directory. | |
Let's say you "vagrant box add" a box named centos.box from an URL | |
vagrant will extract centos.box in your vagrant home folder (the box format is just a tar file) | |
in my case ~/.vagrant.d/boxes/centos | |
In that folder you will see files like : | |
[root@goll tmp]# ls ~/.vagrant.d/boxes/centos65/0/virtualbox/ | |
box-disk1.vmdk box.ovf metadata.json Vagrantfile |
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.function.Function; | |
import java.util.Optional; | |
public class Compile { | |
private <F,T> T runFun(Function<Optional<F>, T> fun, Optional<F> opt) { | |
return fun.apply(opt) ; | |
} | |
public void foo() { | |
Function<Optional<String>, String> fun = o -> o.orElseThrow(() -> new RuntimeException("nah")); |
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/bash | |
# Install nvm: node-version manager | |
# https://github.com/creationix/nvm | |
sudo apt-get install -y git | |
wget https://raw.github.com/creationix/nvm/master/install.sh | |
sh install.sh | |
# TEST: now this should work | |
nvm |
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
public class ByteRangeRequestsController extends Controller { | |
// 206 Partial content Byte range requests | |
private static Result stream(long start, long length, File file) throws IOException { | |
FileInputStream fis = new FileInputStream(file); | |
fis.skip(start); | |
response().setContentType(MimeTypes.forExtension("mp4").get()); | |
response().setHeader(ACCEPT_RANGES, "bytes"); | |
response().setHeader(CONNECTION, "keep-alive"); |
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 com.google.common.util.concurrent.ListeningExecutorService | |
import com.google.common.util.concurrent.MoreExecutors | |
import java.util.concurrent.Executors | |
import com.google.common.util.concurrent.ListenableFuture | |
import com.google.common.util.concurrent.Futures | |
import com.google.common.util.concurrent.FutureCallback | |
import com.google.common.util.concurrent.SettableFuture | |
import java.util.ArrayList | |
object KFutures { |
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
public class ByteRangeRequestsController extends Controller { | |
// 206 Partial content Byte range requests | |
private static Result stream(long start, long length, File file) throws IOException { | |
FileInputStream fis = new FileInputStream(file); | |
fis.skip(start); | |
response().setContentType(MimeTypes.forExtension("mp4").get()); | |
response().setHeader(CONTENT_LENGTH, ((length - start) +1l)+""); | |
response().setHeader(CONTENT_RANGE, String.format("bytes %d-%d/%d", start, length,file.length())); |
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
/* | |
* Copyright (c) 2017 Emil Davtyan | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: |
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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 3 of the License, or | |
# (at your option) any later version. | |
import argparse, dbus, sys | |
bus = dbus.SessionBus() | |
klipper = bus.get_object('org.kde.klipper', '/klipper') |
NewerOlder