Skip to content

Instantly share code, notes, and snippets.

@EtienneR
EtienneR / gist:88ca1158d62ea6e0886d
Created May 14, 2015 19:47
HTML 5 Vibration (only for FirefoxOS and few others http://mobilehtml5.org/)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, maximum-scale=1" />
<title>Vibrate Me</title>
<style>
body{
background: #eee;
margin: 0 auto;
width: 320px;
@EtienneR
EtienneR / foo.json
Last active August 29, 2015 14:27
JSON export file with Go (via io/ioutil)
{"name":"this is the name value","description":"this is the description value","email":"this is the email value"}
@EtienneR
EtienneR / main.go
Last active August 29, 2015 14:27
RSS feed part1
package main
import (
"encoding/xml"
"fmt"
"os"
)
func main() {
type rss struct {
@EtienneR
EtienneR / main.go
Created August 16, 2015 22:20
RSS feed part2
package main
import (
"encoding/xml"
"fmt"
"os"
)
func main() {
type Item struct {
@EtienneR
EtienneR / main.go
Created August 16, 2015 22:24
RSS feed part3
package main
import (
"encoding/xml"
"fmt"
"os"
)
func main() {
type Item struct {
@EtienneR
EtienneR / main.go
Last active August 29, 2015 14:27
RSS feed part4 (webserver)
package main
import (
"encoding/xml"
"net/http"
)
func main() {
http.HandleFunc("/", rssHandler)
http.ListenAndServe(":3000", nil)
@EtienneR
EtienneR / main.go
Created August 16, 2015 22:29
RSS part5 ("pubDate")
package main
import (
"encoding/xml"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", rssHandler)
@EtienneR
EtienneR / main.go
Created August 16, 2015 22:30
RSS bonus (Markdown)
package main
import (
"encoding/xml"
"github.com/russross/blackfriday"
"net/http"
"time"
)
func main() {
@EtienneR
EtienneR / main.go
Created August 19, 2015 20:31
Display files in a folder and then, display file content
package main
import (
"fmt"
"io/ioutil"
"path/filepath"
)
type FileInfo struct {
Name string
@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);