Skip to content

Instantly share code, notes, and snippets.

View mkurz's full-sized avatar
💭
Play Roadmap: https://github.com/orgs/playframework/projects/3

Matthias Kurz mkurz

💭
Play Roadmap: https://github.com/orgs/playframework/projects/3
  • Vienna, Austria
  • 11:51 (UTC +02:00)
View GitHub Profile
@nakamuray
nakamuray / nautilus-disable-recursive-search.patch
Created July 4, 2013 08:52
I don't want nautilus to search directory recursively.
--- nautilus-3.8.2/libnautilus-private/nautilus-search-directory.c.orig 2013-07-04 17:39:05.893879085 +0900
+++ nautilus-3.8.2/libnautilus-private/nautilus-search-directory.c 2013-07-04 17:39:12.226879030 +0900
@@ -171,7 +171,7 @@
nautilus_search_engine_model_set_model (model_provider, search->details->base_model);
simple_provider = nautilus_search_engine_get_simple_provider (search->details->engine);
- g_object_set (simple_provider, "recursive", TRUE, NULL);
+ g_object_set (simple_provider, "recursive", FALSE, NULL);
reset_file_list (search);
@rafi
rafi / install.sh
Created July 3, 2014 12:49
setup msmtp and php
apt-get install msmtp ca-certificates
vim /etc/msmtprc
# Set defaults.
defaults
# Enable or disable TLS/SSL encryption.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
@michalbogacz
michalbogacz / FileZipStream.scala
Last active August 28, 2019 07:08
Creating zip file with Akka Streams.
/*------------------------------------------------------------------------------
* MIT License
*
* Copyright (c) 2019 Michał Bogacz
*
* 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
@kirked
kirked / ZipToStreamFlow.scala
Last active March 6, 2020 21:28
Akka streams implementation of constant-space (per stream) zip file creation.
/*------------------------------------------------------------------------------
* MIT License
*
* Copyright (c) 2017 Doug Kirk
*
* 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
@adriaanm
adriaanm / sam_streams.scala
Last active November 8, 2020 01:28
Playing with Java 8 Stream from Scala 2.11.5
// $ scala-2.11.5 -Xexperimental
// Original Java 8 version: http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
scala> import java.util.{Arrays, List, ArrayList}
scala> import java.util.stream.{Stream, IntStream}
// List<String> myList = Arrays.asList("a1", "a2", "b1", "c2", "c1");
scala> val myList = Arrays.asList("a1", "a2", "b1", "c2", "c1")
@schnerd
schnerd / index.js
Last active January 29, 2021 00:18
index.js
const CDP = require('chrome-remote-interface');
const argv = require('minimist')(process.argv.slice(2));
const file = require('fs');
// CLI Args
const url = argv.url || 'https://www.google.com';
const format = argv.format === 'jpeg' ? 'jpeg' : 'png';
const viewportWidth = argv.viewportWidth || 1440;
const viewportHeight = argv.viewportHeight || 900;
const delay = argv.delay || 0;
import javax.inject.Inject
import scala.concurrent.Future
import play.api.{Configuration, Environment, Mode}
import play.api.inject.{ApplicationLifecycle, Binding, Module}
class DevModeWorkaroundsModule extends Module {
def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
Seq(bind[DevModeWorkarounds].toSelf.eagerly())
}
@kylemanna
kylemanna / price.txt
Created November 30, 2016 17:16
AWS Lightsail vs DigitalOcean, VULTR and Linode
Price breakdown vs DigitalOcean, Vultr and Linode:
RAM / CPU Cores / STORAGE / Transfer
$5/mo
LightSail: 512MB, 1, 20GB SSD, 1TB
DO: 512MB, 1, 20GB SSD, 1TB
VULTR: 768MB, 1, 15GB SSD, 1TB
$10/mo
@tg44
tg44 / Bootstrap.scala
Last active May 11, 2021 14:45
Crowdin CDN from Play framework
import play.api.inject.Module
import helpers.{MessagesApiWithCrowdin, MessagesApiWithCrowdinProvider}
import play.api.i18n.{DefaultLangsProvider, Langs, MessagesApi}
import play.api.inject.Binding
import play.api._
//possibly some imports are missing
class AppStartModule extends Module {
override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
Seq(
@sadache
sadache / gist:4714280
Last active July 14, 2022 15:09
Playframework: Async, Reactive, Threads, Futures, ExecutionContexts

Asynchronicity is the price to pay, you better know what you're paying for...

Let's share some vocabulary first:

Thread: The primitive responsible of executing code on the processor, you can give an existing (or a new) Thread some code, and it will execute it. Normally you can have a few hundreds on a JVM, arguments that you can tweak your way out to thousands. Worth noting that multitasking is achieved when using multiple Threads. Multiple Threads can exist for a single processor in which case multitasking happens when this processor switches between threads, called context switching, which will give the impression of things happenning in parallel. An example of a direct, and probably naive, use of a new Thread in Java:

public class MyRunnable implements Runnable {
  public void run(){
 System.out.println("MyRunnable running");