Skip to content

Instantly share code, notes, and snippets.

@junftnt
junftnt / main.go
Created June 30, 2020 21:07 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@junftnt
junftnt / revprox.go
Created June 23, 2020 15:47 — forked from JalfResi/revprox.go
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@junftnt
junftnt / revprox.go
Created June 23, 2020 01:04 — forked from thurt/revprox.go
Simple reverse proxy in Go (forked from original to use a struct instead of a closure)
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@junftnt
junftnt / introrx.md
Created April 8, 2020 01:15 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@junftnt
junftnt / jsonenv
Created March 30, 2020 18:34 — forked from kr/jsonenv
convert a json dictionary into environment variables
#!/usr/bin/env python
# jsonenv reads a json object as input and produces
# escaped shell commands for setting environment vars
import json
import pipes
import sys
for k, v in json.load(sys.stdin).items():
#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate
@junftnt
junftnt / emailmask.js
Created February 15, 2020 02:25 — forked from gabrielfroes/emailmask.js
Javascript Email Mask
/*
Create a Mask in an email address
This function create a mask using a valid email address.
This is usefull when someone need to confirm the email used in a system
Author: Gabriel Froes - https://gist.github.com/gabrielfroes
*/
function emailMask(email) {
var maskedEmail = email.replace(/([^@\.])/g, "*").split('');
var previous = "";
for(i=0;i<maskedEmail.length;i++){
@junftnt
junftnt / mask.md
Created February 15, 2020 00:05 — forked from gund/mask.md
Simple Angular mask directive

Simple Angular mask directive

This directive does not create it's own value accessor - it simply reuses whatever element is using already and just hooks in.

Also it is fully abstracted off of the HTML implementation and so can be safely used in WebWorker and server side environment.

Usage

@junftnt
junftnt / middleware.py
Created February 3, 2020 19:10 — forked from SehgalDivij/middleware.py
Middleware in django to log all requests and responses(Inspired by another Github gist I cannot find the link to, now)
"""
Middleware to log all requests and responses.
Uses a logger configured by the name of django.request
to log all requests and responses according to configuration
specified for django.request.
"""
# import json
import logging
from django.utils.deprecation import MiddlewareMixin
@junftnt
junftnt / log_requests.py
Created February 3, 2020 18:58 — forked from Suor/log_requests.py
Log HTTP requests in Django
import re, logging
from django.conf import settings
from django.core.handlers.wsgi import STATUS_CODE_TEXT
req_handler = logging.FileHandler(settings.HOME_DIR + '/logs/requests.log')
req_handler.setLevel(logging.INFO)
formatter = logging.Formatter('[%(asctime)s] %(message)s')
req_handler.setFormatter(formatter)