This file contains 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
// Intercepting HTTP calls with AngularJS. | |
angular.module('MyApp', []) | |
.config(function ($provide, $httpProvider) { | |
// Intercept http calls. | |
$provide.factory('MyHttpInterceptor', function ($q) { | |
return { | |
// On request success | |
request: function (config) { | |
// console.log(config); // Contains the data about the request before it is sent. |
This file contains 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
# 'You have new mail' | |
d * | |
q |
This file contains 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
# generate new pair of keys | |
ssh-keygen -f /Users/chris/Desktop/jwt-demo/id_rsa |
This file contains 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
· curl | |
curl -G "https://api.github.com/search/repositories?page=1&per_page=6" --data-urlencode "sort=stars" --data-urlencode "order=desc" --data-urlencode "q=language:html" | jq ".items[0,1,2,3,4,5] | {name, description, html_url}" | |
# set headers | |
curl localhost:8080 --header "jwt: mycooltoken" | |
# display headers | |
curl localhost:8080 -v | |
# show output in new line |
This file contains 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
//naming errors | |
//errErrorName | |
//eg | |
//https://github.com/golang/go/blob/439b32936367c3efd0dadab48dd51202e1a510f1/src/os/error.go#L13 | |
errDB := someFunc() |
This file contains 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 event | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httptest" | |
"testing" | |
"github.com/stretchr/testify/suite" |
This file contains 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 utils | |
func Slugify(title string) string { | |
var slug []byte | |
for _, x := range title { | |
switch { | |
case ('a' <= x && x <= 'z') || ('0' <= x && x <= '9'): | |
slug = append(slug, byte(x)) | |
case 'A' <= x && x <= 'Z': |
This file contains 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 main | |
import ( | |
"encoding/xml" | |
"net/http" | |
"net/url" | |
"fmt" | |
"strings" | |
"io/ioutil" | |
"encoding/json" |
This file contains 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 main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"net/url" | |
"regexp" | |
"strings" | |
) |
This file contains 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 main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"net/url" | |
"regexp" | |
"strings" | |
) |