Skip to content

Instantly share code, notes, and snippets.

@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();
@johnnncodes
johnnncodes / gist:9725c0702762e41ad68b
Created December 11, 2014 23:55
Multiple apps directory structure for AngularJS
projectname/
README.md
.gitignore
bower.json
package.json
node_modules/
bower_components/
bin/
script1
script2
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
1 Tipperary (IRE)
2 Musselburgh
3 Epsom
4 Santa Anita (USA)
5 Caulfield (AUS)
6 Sha Tin (HK)
7 Chantilly (FR)
8 Dusseldorf (GER)
9 Hanover (GER)
10 Chantilly (fr) (ARAB)