Skip to content

Instantly share code, notes, and snippets.

View zevisert's full-sized avatar

Zev Isert zevisert

View GitHub Profile
@zevisert
zevisert / mailgun_validate.js
Created March 30, 2017 22:36
This file merges mailgun validation functionality with jQuery Validation Plugin's surprisingly poor async validation customizability.
/**
* Created by zevisert on 2017-03-27.
* This file merges mailgun validation functionality with jQueryValidationPlugin's surprisingly
* poor async validation customizability. Much of this code has been borrowed from
* * jQuery Validation remote method
* - https://github.com/jquery-validation/jquery-validation/blob/master/src/core.js#L1477
* * Mailgun validator jquery plugin
* - https://github.com/mailgun/validator-demo/blob/master/mailgun_validator.js#L30
*
*
@zevisert
zevisert / Discover-Services-Available.js
Last active February 28, 2017 07:08
Discovering Recollect's API
function test_service(place, i) {
return fetch(`https://recollect.net/api/places/${place}/services/${i}`).then(response => {
if (response.ok){
return response.json();
} else return {};
});
}
function discover_services(place) {
let existing_services = {};
@zevisert
zevisert / auth.service.ts
Last active December 12, 2016 22:22
Auth Service
@Injectable()
export class AuthService {
...
validate(pattern: string, route: string): void {
let body: AuthBody = { type: "Anonymous", payload: pattern };
// Fire off a request to the server to see if the pattern entered is valid
this.postAuth(body)
@zevisert
zevisert / blog.service.ts
Created December 12, 2016 22:18
Blog Service
@Injectable()
export class BlogService {
private allPostsUrl = "api/posts";
private singlePostUrl = "api/post/";
private cachedPosts: PostData[];
private cachedPromise: Promise<PostData[]>;
// Angular2-jwt nicely attaches the token to every request for us
constructor(@Inject(AuthHttp) private http: AuthHttp) { }
@zevisert
zevisert / post.component.ts
Last active December 12, 2016 22:16
Post Component
@Component({...})
export class PostComponent implements OnInit {
post: Post;
constructor(
@Inject(BlogService) private blogService: BlogService,
@Inject(ActivatedRoute) private activatedRoute: ActivatedRoute
) { }