Skip to content

Instantly share code, notes, and snippets.

View mchv's full-sized avatar

Mariot Chauvin mchv

View GitHub Profile

Todo

  • Add sources and links to relevant issues
  • Add sentences

Sources

@mchv
mchv / Controller.scala
Last active June 30, 2017 16:56
Old style playframework controller to reduce boilerplate
package play.api.mvc.legacy
import play.api.mvc._
class Controller extends BaseController {
override protected def controllerComponents: ControllerComponents = {
Controller.components /* we don't null check here to avoid the cost associated to it - we expect devs to have done the init properly */
}
for bucket in $(aws s3api list-buckets --query 'Buckets[*].{Name:Name}' --output text)
do
echo "$bucket:"
region=$(aws s3api get-bucket-location --bucket $bucket --query 'LocationConstraint' --output text | awk '{sub(/None/,"eu-west-1")}; 1')
parts=$(aws s3api list-multipart-uploads --bucket $bucket --region $region --query 'Uploads[*].{Key:Key,UploadId:UploadId}' --output text)
if [ "$parts" != "None" ]; then
IFS=$'\n'
@mchv
mchv / fastly_soft-purge.sh
Created June 13, 2016 14:56
Fastly soft purge
FILEPATH=<YOUR PATH>
FASTLY_SERVICE_ID=<YOUR ID>
FASTLY_API_KEY=<YOUR API KEY>
SURROGATE_KEY=`md5 -qs '$FILEPATH'`
curl -X POST --header "Fastly-Soft-Purge: 1" --header "Fastly-Key: ${FASTLY_API_KEY}" https://api.fastly.com/service/${FASTLY_SERVICE_ID}/purge/${SURROGATE_KEY}
--- kcompat.h 2014-11-05 18:14:14.780832000 +0000
+++ kcompat-modified.h 2014-11-05 18:16:53.552832000 +0000
@@ -3172,8 +3172,6 @@
#define u64_stats_update_begin(a) do { } while(0)
#define u64_stats_update_end(a) do { } while(0)
#define u64_stats_fetch_begin(a) do { } while(0)
-#define u64_stats_fetch_retry_bh(a) (0)
-#define u64_stats_fetch_begin_bh(a) (0)
#if (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,1))
@mchv
mchv / Elasticsearch Terms Vector API example
Created May 30, 2014 08:16
Elasticsearch Terms Vector API example
import org.elasticsearch.action.ActionListener
import org.elasticsearch.action.termvector.TermVectorResponse
import org.elasticsearch.action.termvector.TermVectorRequestBuilder
import org.elasticsearch.common.xcontent.ToXContent
import org.elasticsearch.common.xcontent.XContentBuilder
import org.elasticsearch.common.xcontent.XContentFactory
import org.elasticsearch.common.xcontent.XContentType
def getTermsVector(`type`: String, id: String, field: String) {
val builder = new TermVectorRequestBuilder(client, index, `type`, id).setSelectedFields(field)
import java.io.*;
import java.util.jar.JarEntry;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
public class JarBug {
public static void main(String[] args) throws IOException {
generateLargeJar(new File("buggyjar.jar"));