Skip to content

Instantly share code, notes, and snippets.

@bessey
bessey / run.sh
Last active December 13, 2015 18:08
Blue Crystal job submitter, features: - Runs make - Submits the job file './lb_submit' - Moves output to '../(CURRENT-FOLDER-NAME)-reports/' - Ctrl+c cancels job - cats the output of report to screen - takes a parameter for the job title
#!/bin/zsh
# Handy run script.
# Call with './run.sh "<COMMENT>" where <COMMENT> is replaced with your title for the run.
# <COMMENT> must be in quotes.
function itsatrap()
{
echo "Aborting job $jnum"
qdel $jnum
exit 2
}
@bessey
bessey / general_run.sh
Last active December 14, 2015 19:48
Run script for HPC examples / general code. Takes a submission file as an argument and works out from the submission file what output files to expect from qsub. Basically made to avoid having to customise job files to the script!
#!/bin/zsh
# Handy run script.
# Call with './run.sh <JOB_SUB> "<COMMENT>"
# <JOB_SUB> is replaced by your job submission file.
# <COMMENT> is replaced with your title for the run.
# Your <
# <COMMENT> must be in quotes.
#
# Original Author: Drummond Ogilvie
# Released under the DBAD license:
class Parent < ActiveRecord::Base
has_many :children
end
class Child < ActiveRecord::Base
has_one :parent
has_many :sub_children
def self.method
# I want this to have a conditional .where("child.parent_id" => parent_id) if I called .method via the parent model,
For those not present for the FB messenger clusterfuck, heres the key points:
Tomorrow (Wednesday), we are booking a place. This is number 1 choice atm:
http://www.homeaway.com/vacation-rental/p502890vb
Its near the gondola and the casinos
(ASSUMPTIONS AHEAD, CORRECT IF WRONG)
There will be 3 cars driving there and back
Michael's own one
@bessey
bessey / example.rb
Last active August 29, 2015 14:05
My ideal v3 directory client.
##### In my app
class Account < DirectoryClient::Base
def self.specific_convenient_scope_method
where(blah: "blah").order(:bloo)
end
end
Account.all
# Handles OAuth authentication and reauthentication on timeout
# Introspects class name to work out api endpoint (/api/v3/accounts)
@bessey
bessey / trado notes.md
Created October 14, 2014 13:25
trado notes

Inconsistent tab size (2 / 4 spaces). Easy fix, run through Rubocop.

Might be an idea to have a GH pages site that better markets the tool towards non techies? README seems to try and bundle together marketing lingo with technical details.

Also an example app running somewhere perhaps, that resets every night or something?

We have a similar thing to your DynamicRouter in Caring.com and I would not recommend it! Your use case might be significantly different enough to justify it, but metaprogramming with routes makes debugging a nightmare, if you can, make them namespaced, even if its just /p/:page_slug so you can have regular route helpers, and you don't need to redeclare your routes every time a page is edited.

I probably wouldn't have things like postgres (unless you're using PG exclusive features), unicorn, rollbar, and newrelic in as hard dependencies; we love them but other users of trado have workflows they already use. Maybe make trado a rails engine that is designed to be mounted at the root

from PyQt4 import QtGui
from PyQt4 import QtCore
from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT
import sys
# They're defining a class that extends LCD, so they can create
class myLCDNumber(QtGui.QLCDNumber): # a function to allow the LCD to change itself
value = 60
@pyqtSlot() # I don't think you need to worry about this line
def count(self): # Here's the important bit, defining a method that changes the LCD's value on execution
@bessey
bessey / throwApolloError.jsx
Last active November 29, 2016 23:12
Apollo error workaround
import React, { Component, PropTypes } from "react"
// Fixes a silly bug in Apollo where certain errors are not propagated to the console
const throwApolloError = function(WrappedComponent) {
return class ApolloErrorThrower extends Component {
static propTypes = {
data: PropTypes.shape({
error: PropTypes.object
})
@bessey
bessey / snippets.js
Created December 8, 2016 20:43
my "JavaScript React" snippets for VS Code
{
/*
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
@bessey
bessey / Error message
Created December 23, 2016 05:15
Mocked graphql schema, and the error it generates
Expected a value of type "Time" but received: 2016-12-23T05:04:10.611Z