This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Load the http module to create an http server. | |
| var http = require('http'); | |
| // Create a function to handle every HTTP request | |
| function handler(req, res){ | |
| var form = ''; | |
| if(req.method == "GET"){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Load the http module to create an http server. | |
| var http = require('http'); | |
| // Create a function to handle every HTTP request | |
| function handler(req, res){ | |
| res.setHeader('Content-Type', 'text/html'); | |
| res.writeHead(200); | |
| res.end("<html><body><h1>Hello</h1></body></html>"); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Form Calculator Add Example</title> | |
| </head> | |
| <body> | |
| <form name="myForm" action="" onsubmit="return calc(this['A'].value,this['B'].value);" method="post"> | |
| <input type="text" name="A"> + | |
| <input type="text" name="B"> = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta name="description" content="Page Description for Search Engines"/> | |
| <title>HTML5 Basic Structure</title> | |
| <link rel="stylesheet" href="http://necolas.github.io/normalize.css/3.0.1/normalize.css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Assuming jQuery Ajax instead of vanilla XHR | |
| */ | |
| //Get Github Authorization Token with proper scope, print to console | |
| $.ajax({ | |
| url: 'https://api.github.com/authorizations', | |
| type: 'POST', | |
| beforeSend: function(xhr) { | |
| xhr.setRequestHeader("Authorization", "Basic " + btoa("USERNAME:PASSWORD")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m.Get("/cards/:players", allowCORSHandler, func(args martini.Params, r render.Render) { | |
| Shuffle(cards) | |
| //use Atoi as ParseInt always does int64 | |
| p, _ := strconv.Atoi(args["players"]) | |
| if(p==0 || p>52){ | |
| //not valid number | |
| r.JSON(200, cards) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package hello | |
| import ( | |
| "net/http" | |
| "github.com/go-martini/martini" | |
| "github.com/martini-contrib/cors" | |
| "github.com/martini-contrib/render" | |
| "math/rand" | |
| ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package hello | |
| import ( | |
| "net/http" | |
| "github.com/go-martini/martini" | |
| "github.com/martini-contrib/cors" | |
| "github.com/martini-contrib/render" | |
| ) | |
| type Resources struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // jXHR.js (JSON-P XHR) | v0.1 (c) Kyle Simpson | MIT License | |
| (function(c){var b=c.setTimeout,d=c.document,a=0;c.jXHR=function(){var e,g,n,h,m=null;function l(){try{h.parentNode.removeChild(h)}catch(o){}}function k(){g=false;e="";l();h=null;i(0)}function f(p){try{m.onerror.call(m,p,e)}catch(o){throw new Error(p)}}function j(){if((this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded")||g){return}this.onload=this.onreadystatechange=null;g=true;if(m.readyState!==4){f("Script failed to load ["+e+"].")}l()}function i(o,p){p=p||[];m.readyState=o;if(typeof m.onreadystatechange==="function"){m.onreadystatechange.apply(m,p)}}m={onerror:null,onreadystatechange:null,readyState:0,open:function(p,o){k();internal_callback="cb"+(a++);(function(q){c.jXHR[q]=function(){try{i.call(m,4,arguments)}catch(r){m.readyState=-1;f("Script failed to run ["+e+"].")}c.jXHR[q]=null}})(internal_callback);e=o.replace(/=\?/,"=jXHR."+internal_callback);i(1)},send:function(){b(function(){h=d.createElement("script");h.setAttr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Post struct { | |
| // db tag lets you specify the column name if it differs from the struct field | |
| Id int64 `db:"post_id"` | |
| Created int64 | |
| Title string `form:"Title" binding:"required"` | |
| Body string `form:"Body"` | |
| UserId int64 `form:"UserId"` | |
| Url string | |
| } |