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
| class AuthenticatedUserResourceMixin(ResourceMixin): | |
| permissions = (IsAuthenticated,) | |
| def build_query(self, *args, **kwargs): | |
| tmp = dict(kwargs) | |
| if BaseRenderer._FORMAT_QUERY_PARAM in tmp: | |
| del tmp[BaseRenderer._FORMAT_QUERY_PARAM] |
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
| class AutoCompleteResourceMixin(ResourceMixin): | |
| def validate_request(self, data, files=None): | |
| """ | |
| Auto-complete objects when they are created. | |
| A REST equivalent to auto-populate for Django web forms. | |
| """ | |
| method = self.view._method if hasattr(self.view, '_method') else None |
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 xmlns:ng="http://angularjs.org"> | |
| <meta charset="UTF-8" /> | |
| <script src="http://code.angularjs.org/angular-0.9.19.min.js" ng:autobind></script> | |
| <body> | |
| <zippy class="open"> | |
| <header>Greeting</header> | |
| <pane>Hello World!</pane> | |
| </zippy> |
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
| // service.js | |
| angular.service('Address', function($resource, $cookies, $xhr, $log) { | |
| // Add Header to comply with Django's CSRF implementation | |
| token = $cookies['csrftoken']; | |
| $xhr.defaults.headers['delete']['X-CSRFToken'] = token; | |
| return $resource('/api/user/address/:addressId', {addressId:'@id'}, {}); | |
| }); |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>icon-template</key> | |
| <array> | |
| <string>tmpl</string> | |
| </array> | |
| <key>icon-xml</key> | |
| <array> |
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
| POST /api/authenticate | |
| > Content-Type: application/x-www-form-urlencoded | |
| > | |
| user=lars,pass=secret | |
| < 200 OK | |
| < | |
| { | |
| "token": "897ca80f3443de1ad9c0ce8f9d7c4449c68606e0" | |
| } |
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os, string | |
| def random_password(length=14): | |
| """ | |
| Random password generator. | |
| Default generated password will have an entropy of 84 bits. |
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 main | |
| import ( | |
| "archive/zip" | |
| "flag" | |
| "log" | |
| "net/http" | |
| "golang.org/x/tools/godoc/vfs/httpfs" | |
| "golang.org/x/tools/godoc/vfs/zipfs" |
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 person_test | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| // Person is a modern human with a name. | |
| type Person struct { | |
| name string |
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
| snippet tt "table-driven tests" | |
| func Test${1:Func}(t *testing.T) { | |
| testCases := []struct { | |
| ${2:input} ${3:Type} | |
| want ${4:Type} | |
| }{ | |
| {$2: ${5:""}, want: ${6:""}},${0: // comment} | |
| } | |
| for _, tc := range testCases { | |
| if got := $1(tc.$2); got != tc.want { |
OlderNewer