Skip to content

Instantly share code, notes, and snippets.

@mihkels
mihkels / silex-php.conf
Last active January 31, 2016 13:50 — forked from simonjodet/gist:2713959
Pretty URLs for Silex micro-framework using Nginx. Added GET query parameters support. I prefer to run ngnix server virtual host configurations on none standard ports because it requires zero configuration in hosts file.
server {
listen 8080;
server_name localhost;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
root /path/to/silex/web/;
index index.php;
@mihkels
mihkels / gist:5080555
Created March 4, 2013 07:06
Load multiple dump files into database
zcat dump_one.sql.gz | mysql --user=root --password=root db1 && zcat dump_2.sql.gz | mysql --user=root --password=root db2
@mihkels
mihkels / 1-req.sh
Last active October 24, 2022 19:20
Ubuntu 12.04 with flask + nginx + uwsgi
#!/bin/bash
sudo apt-get update
# Now let's install all the required ubuntu packages
sudo apt-get install build-essential uwsgi nginx uwsgi-plugin-python python-pip
# PS! If you are doing this stuff for fun I do recommend to install nginx from PPA repository
# that you can find here https://launchpad.net/~nginx/+archive/development
@mihkels
mihkels / MultiConnectionSupport.java
Created March 2, 2016 13:51
Spring Boot with Letsencrypt SSL certificate support
@Configuration
public class MultiConnectionSupport {
@Value("${server.port}")
private int serverPort;
@Value("${server.http.port}")
private int httpServerPort;
@Bean
public EmbeddedServletContainerFactory servletContainer() {
@mihkels
mihkels / PrivateConstructorTest.java
Last active January 4, 2017 15:06
Sometimes (i.e util classes) there is need to verify in tests that constructor is private. Best way in my opinion is to do it using Java reflection and below is almost drop in solution how it should be done. Only thing that needs to be replaced is the class under test
public class PrivateConstructorTest {
@Test
public void utilClassConstructorMustBePrivate() throws Exception {
// Replace ReportBuilderUtils with class name under test
final Constructor<ReportBuilderUtils> constructor = ReportBuilderUtils.class.getDeclaredConstructor();
assertThat(Modifier.isPrivate(constructor.getModifiers())).isTrue();
constructor.setAccessible(true);
constructor.newInstance();
}
@mihkels
mihkels / browserify_bootstrap_index.js
Last active December 30, 2016 10:06
Browserify ES6 importing Bootstrap JavaScript
// Importing jQuery in ES6 style
import $ from "jquery";
// We need to expose jQuery as global variable
window.jQuery = window.$ = $;
// ES6 import does not work it throws error: Missing jQuery
// using Node.js style import works without problems
require('bootstrap');
@mihkels
mihkels / gist:40d1f321263093735955fe156affeef2
Last active January 4, 2017 15:07
Find and remove IntelliJ project .iml files
find . -name "*.iml" -exec rm -rf {} \;
@mihkels
mihkels / gitbashAdmin.bat
Last active February 22, 2017 11:43 — forked from yoavniran/gitbashAdmin.bat
ConEmu - Run GitBash as Admin
"%ConEmuDrive%\Program Files\Git\bin\sh.exe" --login -i -new_console:a
docker stop $(docker ps -a -q)
@mihkels
mihkels / docker-compose-app.yml
Created March 29, 2017 12:09
Run Zookeeper and Kafka with docker-compose. Also support to send app logs to Kafka using elastic Filebeat
version: "3"
services:
sample_app:
# PHP 7 with ZeroMQ installed
build: .
depends_on:
- filebeat
working_dir: /app
command: php index.php
volumes: