Skip to content

Instantly share code, notes, and snippets.

@junftnt
junftnt / movie-titles.rb
Created June 29, 2017 23:02 — forked from karmi/movie-titles.rb
Multiple analyzers and query fields in Elasticsearch for auto-completion
require 'tire'
# Tire.configure { logger STDERR, level: 'debug' }
Tire.index('movie-titles') do
delete
create \
settings: {
index: {
analysis: {
@junftnt
junftnt / vimdiff.md
Created July 5, 2017 19:12 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@junftnt
junftnt / nginx.conf
Created September 22, 2017 17:35 — forked from atomaths/nginx.conf
This is a FastCGI example server in Go.
## FastCGI
server {
location ~ /app.* {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
## Reverse Proxy (이 방식으로 하면 http.ListenAndServe로 해야함)
server {
@junftnt
junftnt / redirectExample.go
Created December 19, 2017 01:48 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@junftnt
junftnt / sse.go
Created January 18, 2018 22:07 — forked from ismasan/sse.go
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// 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
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@junftnt
junftnt / form-script.html
Created January 24, 2018 02:23 — forked from emcode/form-script.html
How to convert HTML form data to JS object (for using with AJAX)
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>How to convert HTML form data to JS object (for using with AJAX)</title>
</head>
<body>
<form id="contact-form" action="/" method="post">
@junftnt
junftnt / notepad.html
Created February 23, 2018 01:25 — forked from jdkanani/notepad.html
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@junftnt
junftnt / linkify.php
Created March 9, 2018 18:38 — forked from jasny/linkify.php
PHP function to turn all URLs in clickable links
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @param string $mode normal or all
* @return string
*/
@junftnt
junftnt / reverseProxy.go
Created May 4, 2018 17:18 — forked from rolaveric/reverseProxy.go
Example of a reverse proxy written in Go
import (
"net/http"
"net/http/httputil"
"net/url"
"fmt"
)
func main() {
// New functionality written in Go
http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) {

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: