Skip to content

Instantly share code, notes, and snippets.

View jlprat's full-sized avatar

Josep Prat jlprat

View GitHub Profile
#!/bin/bash
filename_extension="${1##*.}"
if [[ "$filename_extension" != "md5" ]] && [[ "$filename_extension" != "sha1" ]] && [[ "$filename_extension" != "sha512" ]]; then
echo "Hash algorithm not supported, choose between sha1, sha512, or md5"
exit 1
fi
while IFS=":" read -r filename hash_code; do
computed_hash=$(openssl dgst -"$filename_extension" "$filename" | awk '{print $2}')
@jlprat
jlprat / ffmpeg.cookbook.md
Created October 17, 2022 18:30
ffmpeg cookbook

Change format of video

ffmpeg -i source.webm target.mov

Change length of video

This gets the first 10 seconds of the video

[ERROR] [04/27/2017 13:41:56.845] [pool-6-thread-8-ScalaTest-running-PathDirectivesSpec] [akka.actor.ActorSystemImpl(akka-http-scaladsl-server-directives-PathDirectivesSpec)] Error during processing of request: 'Rejection handler still produced new rejections after 8 iterations. Is there an infinite handler cycle? Initial rejections: List() final rejections: List()'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
java.lang.RuntimeException: Rejection handler still produced new rejections after 8 iterations. Is there an infinite handler cycle? Initial rejections: List() final rejections: List()
at scala.sys.package$.error(package.scala:27)
at akka.http.scaladsl.server.directives.ExecutionDirectives$$anonfun$handleRejections$1.akka$http$scaladsl$server$directives$ExecutionDirectives$class$$anonfun$$handle$1(ExecutionDirectives.scala:55)
at akka.http.scaladsl.server.directives.ExecutionDirectives$$anonfun$handleRejections$1
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.{ HttpApp, Route }
import spray.json.DefaultJsonProtocol
case class SomeFooData(foo: String)
object SomeFooDataSupport extends DefaultJsonProtocol with SprayJsonSupport {
implicit val PortofolioFormats = jsonFormat1(SomeFooData)
}
@jlprat
jlprat / emacs init.el
Last active March 14, 2017 12:27
Init.el file for emacs to be configured with Ensime, helm, and zoom-frm
; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
use-package-always-ensure t
sentence-end-double-space nil
import akka.http.javadsl.marshallers.jackson.Jackson;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.StatusCodes;
import akka.http.javadsl.server.Route;
import akka.http.javadsl.testkit.JUnitRouteTest;
import org.junit.Test;
import java.util.Optional;
public class RejectEmptyResponseBug extends JUnitRouteTest {
@jlprat
jlprat / Drools5.5.0.java
Last active August 29, 2015 13:59
Gist describing a problem while migrating to Drools 6.0.1 from Drools 5.5.0. The snippets contain the same test situation using drools 5.5.0, then 6.0.1 using fireAllRules, and finally using fireUntilHalt. As we have rules that use timers, and this ones might cause other rules to be triggered, we can't use fireAllRules even if using the TimedRul…
// With Drools 5.5
@Before
public void setupSession() {
final KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
final KnowledgeBuilder kbuilder = TestHelper.buildRules();
kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
ksession = kbase.newStatefulKnowledgeSession();
}