Skip to content

Instantly share code, notes, and snippets.

View JusticeN's full-sized avatar

Justice Nanhou JusticeN

View GitHub Profile
@jfeng45
jfeng45 / go2ErrorHandlingSimplified.md
Last active November 9, 2022 11:44
A simplified Go 2 error handling solution with no handler

I propose a simplified Go 2 error handling solution with no handler, which can solve 80% of the problems.  Here is an example of the current error handling code:

// Top layer
func main() {
   src :="test"
   f, err := funcLevel1(src)
   if err != nil {
 fmt.Println(err)
@lukassup
lukassup / zipapp.md
Last active September 12, 2023 02:17
Python zipapp

Python zipapp web apps

What's a zipapp?

This concept is very much like .jar or .war archives in Java.

NOTE: The built .pyz zipapp can run on both Python 2 & 3 but you can only build .pyz zipapps with Python 3.5 or later.

Initial setup

@JusticeN
JusticeN / nginxproxy.md
Created August 15, 2016 18:04 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

import random
import time
import numpy
from exceptions import ValueError
class PushID(object):
# Modeled after base64 web-safe chars, but ordered by ASCII.
PUSH_CHARS = ('-0123456789'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@ryochack
ryochack / 20140316-205912.go
Created March 16, 2014 13:28
golang reflection: interface of array
package main
import (
"fmt"
"reflect"
)
func dump_interface_array(args interface{}) {
val := reflect.ValueOf(args)
fmt.Println(val.Kind())
@mschoebel
mschoebel / main.go
Created March 6, 2014 20:02
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@LeeSanghoon
LeeSanghoon / ShortUUID.java
Last active May 29, 2023 19:35
Generate short UUID
import java.nio.ByteBuffer;
import java.util.UUID;
/**
* Generate short UUID (13 characters)
*
* @return short UUID
*/
public static String shortUUID() {
UUID uuid = UUID.randomUUID();
@fcurella
fcurella / psql.py
Created August 27, 2012 16:22
postgres PubSub vs Redis
#!/usr/bin/env python
import select
import time
import psycopg2
import psycopg2.extensions
import sys
def get_cursor():
conn = psycopg2.connect("dbname=pgpubsub")
@defims
defims / index.html
Created August 21, 2012 18:31
pure css mindmap with nest list element.
<div class="topic">
topics
<ul>
<li>this is a long subtopic and conetent</li>
<li>topic2</li>
<li>topic3</li>
<li>topic4</li>
<li>topic5</li>
<li>topic6 it's also very long</li>
<li>topic7</li>