Skip to content

Instantly share code, notes, and snippets.

View asit-dhal's full-sized avatar

Asit Kumar Dhal asit-dhal

View GitHub Profile
#!/usr/bin/env python
# An example of decoding/encoding datetime values in JSON data in Python.
# Code adapted from: http://broadcast.oreilly.com/2009/05/pymotw-json.html
from datetime import datetime
import json
from json import JSONDecoder
from json import JSONEncoder
@asit-dhal
asit-dhal / cmdoptions.cpp
Created June 3, 2016 13:53 — forked from randomphrase/cmdoptions.cpp
Demonstration of how to do subcommand option processing with boost program_options
#define BOOST_TEST_MODULE subcommand options
#include <boost/test/unit_test.hpp>
#include <boost/program_options.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct GenericOptions {
bool debug_;
};
@asit-dhal
asit-dhal / hello-world-concurrency.cpp
Created August 19, 2016 14:30
Gist created by fiddle.jyt.io
// "Copyright [2016] <Asit Dhal, dhal.asitk@gmail.com>"
#include <thread>
#include <iostream>
#include <chrono>
#include <string>
#include <sstream>
#include <functional>
#include <algorithm>
#include <vector>
package main
import (
"net/http"
"html/template"
)
func handler(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("view.html") //setp 1
t.Execute(w, "Hello World!") //step 2
package main
import (
"net/http"
"html/template"
)
func handler(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("view.html") //setp 1
t.Execute(w, "Hello World!") //step 2
package main
import (
"html/template"
"net/http"
)
var tmpl = `<html>
<head>
<title>Hello World!</title>
package main
import (
"net/http"
"html/template"
)
func handler1(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("t1.html", "t2.html")
t.Execute(w, "Asit")
}
@asit-dhal
asit-dhal / defineActionDemo.go
Created September 17, 2016 02:39
define action demo golang template
package main
import (
"fmt"
"html/template"
"os"
)
var defineDemo = `
{{ define "a" }} Template A {{ end }}
@asit-dhal
asit-dhal / output
Last active September 17, 2016 03:07
template action demo
Template A includes Template B
Template B
Template A ends
package main
import (
"fmt"
"html/template"
"os"
)
var templateDemo = `
{{ define "a" }}