Skip to content

Instantly share code, notes, and snippets.

/**
* Interceptor
* Implements functionality to catch various requests and fire events when they happen. This is generally to ensure
* that responses from the server are handled in a uniform fashion across the application. Also, by firing events
* it allows to have any number of handlers attach to the response.
*
* @author Kirk Bushell
* @date 28th March 2013
*/
var module = angular.module('core.interceptor', []);
@johnnncodes
johnnncodes / upload.js
Last active August 29, 2015 14:10 — forked from thekarel/upload.js
var util = require('util');
it('should upload file', function() {
var fileToUpload = '../some/path/foo.txt';
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
from django.contrib.sites.models import Site
class Object(object):
def __init__(self, model, key):
self.model = model
self.key = key
def __call__(self, *args, **kwargs):
params = {}
<?php
class PostEntity
{
private $id;
private $user;
private $title;
private $content;
private $date;
<?php
trait EventGenerator
{
protected $pendingEvents = array();
protected function raise($event)
{
$this->pendingEvents[] = $event;
}
@johnnncodes
johnnncodes / gist:2275096cd3409da2ee73
Created March 13, 2016 01:42 — forked from jayuen/gist:6787780
DateWithTimezone
define("DateWithTimezone", function(module) {
var DateWithTimezone = function(moment){
this.moment = moment
moment.tz(DateWithTimezone.getTimezone())
}
_.extend(DateWithTimezone.prototype, {
toISO: function(){
return this.format()
},
package main
import (
"fmt"
"reflect"
"net/url"
)
type ExampleType struct {
Name string `url:"name"`
@johnnncodes
johnnncodes / db_backup.sh
Created February 1, 2017 15:14 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
@johnnncodes
johnnncodes / README.md
Created April 10, 2019 06:20 — forked from wankdanker/README.md
Walmart Drop Ship Vendor Supplier DSV Carrier Method Codes

Walmart Drop Ship Vendor Supplier DSV Carrier Method Codes

As part of the Walmart DSV API, there are carrier method codes in the order xml, but the only documentation I found was in this PDF. That document is referenced from Supplier Help.

That PDF file is of course not easily consumable and it was a wicked pain in the ass to get the data out of there. But, it's done now, and if you happen to find this file I hope I saved you some time.