Skip to content

Instantly share code, notes, and snippets.

@ydcode
ydcode / FooRepository.php
Created May 9, 2016 06:20 — forked from bigcalm/FooRepository.php
Making an entity repository container aware in Symfony2.1
<?php
namespace Acme\DemoBundle\Repository;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Doctrine\ORM\EntityRepository;
/**
@ydcode
ydcode / gist:9dc23266b5896a35c6f47db7808462dc
Created May 31, 2016 12:31 — forked from arsisakarn/gist:1450450
Symfony 2 set and read cookie
<?php
public function testSetCookieAction()
{
$value = '12345';
$html = '<html><body>test set cookie varName =' . $value . '</body></html>';
$response = new Response($html);
$response->headers->setCookie(new Cookie('varName', $value, time() + (3600 * 48)));
return $response;
}
@ydcode
ydcode / Job.java
Created February 13, 2017 01:55 — forked from chiwanpark/Job.java
Flink Inherited POJO Example
package com.chiwanpark.flink;
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
// 新增當地時區的時間物件
function DateTimezone(offset) {
// 建立現在時間的物件
d = new Date();
// 取得 UTC time
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// 新增不同時區的日期資料
@ydcode
ydcode / Entity.java
Created December 14, 2017 18:33 — forked from framis/Entity.java
JPA to Json Converter
@Entity
public class Entity {
@Id
@GeneratedValue
private Long id;
@Convert(converter = JpaJsonConverter.class)
private Map<String, String> customMap;
}
@ydcode
ydcode / docker-cleanup-resources.md
Created February 12, 2018 02:24 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ydcode
ydcode / regex-console.text
Created April 26, 2018 10:44
Remove all console.log from JS in Sublime
Ensure regex button is selected and then type this in the search field.
\s*console\.log(.*);
@ydcode
ydcode / SpringBootUndertowHTTP2.java
Created May 9, 2018 17:13 — forked from barlog-m/SpringBootUndertowHTTP2.java
Enable HTTP2 in Undertow with Spring Boot
public class SpringBootUndertowHTTP2 {
@Bean
UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
factory.addBuilderCustomizers(
builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
return factory;
}
}
@ydcode
ydcode / aws-ec2-redis-cli.md
Created June 13, 2018 21:21 — forked from paladini/aws-ec2-redis-cli.md
AWS redis-cli without redis server on AWS EC2

Setup redis-cli without the whole Redis Server on AWS EC2

This fast tutorial will teach you how to install redis-clion AWS EC2 without having to install the whole Redis Server. Firstly, SSH into your EC2 instance and run the following command:

$ sudo yum install gcc

This may return an "already installed" message, but that's OK. After that, just run:

$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make && sudo cp src/redis-cli /usr/local/bin/ && sudo chmod 755 /usr/local/bin/redis-cli

@ydcode
ydcode / postfix-dovecot-ubuntu14.04.sh
Created November 14, 2018 03:33 — forked from haisum/postfix-dovecot-ubuntu14.04.sh
Automated bash script to setup dovecot postfix mysql email server on ubuntu 14.04
#!/usr/bin/env bash
#####
# Script to install postfix
#####
DOMAIN="example.com"
EMAIL="haisum@example.com"
PASSWORD="example.com1*"