Skip to content

Instantly share code, notes, and snippets.

@derwolfe
derwolfe / longrunning.py
Last active August 29, 2015 14:02
example of long running task with intermediate status result
# XXX many of the addBoths should be changed to involve error handling
"""
longrunning
This is an example of how one can develop a system using twisted.web
that can process long running results but still provide a short
request-response cycle.
This implements the following pattern:
1) request received by twisted application
@derwolfe
derwolfe / new output with verbose
Last active August 29, 2015 13:57
gdb/rust symbols
(gdb) set verbose
(gdb) b main
Breakpoint 1 at 0x100000e70
(gdb) r foo.rs --out-dir ./bar/baz
Starting program: /Users/chris/Code/rust/x86_64-apple-darwin/stage1/bin/rustc foo.rs --out-dir ./bar/baz
warning: platform-specific solib_create_inferior_hook did not load initial shared libraries.
# this is on os x
@derwolfe
derwolfe / make
Last active August 29, 2015 13:55
makefile with test, build, clean etc. Not excellent make, but works.
# you should put all of the tests to be run for each of the
# files as they are being built
CC=rustc
BUILDDIR=~/Code/matasano/rust/build
DOCDIR=~/Code/matasano/rust/docs
CCFLAGS=--out-dir $(BUILDDIR)
DC=rustdoc --output $(DOCDIR)
all: score single_cipher decrypt_single fixed_xor encode64
@derwolfe
derwolfe / gist:7714874
Created November 30, 2013 03:02
raw header returned
[('Date', ['Sat, 30 Nov 2013 03:01:37 GMT']),
('Last-Modified', ['Sat, 30 Nov 2013 03:01:37 GMT']),
('Accept-Ranges', ['bytes']),
('Content-Type', ['text/plain']),
('Server', ['TwistedWeb/13.1.0'])]
.directive('sides', function () {
return {
// this seems to solve the problem - don't use link, use a built in controller.
controller: function ($scope) {//, elem, attrs) {
$scope.sides = [
{ Name: 'Buy', Id: 1 },
{ Name: 'Sell', Id: -1 }
];
$scope.side = $scope.sides[0];
},
.directive('sides', function() {
// not working
return {
scope: {
sides: [
{ Name: 'Buy', Id: 1 },
{ Name: 'Sell', Id: -1 }
]
},
restrict: 'A',
var app = angular.module('App', ['restangular']);
app.config(function (RestangularProvider) {
RestangularProvider.setBaseUrl('/api');
RestangularProvider.setDefaultHeaders({
"headers": { "common": { "Accept": "application/json" } }
});
});
// service that fetches all of the static information that will be needed
angular.module('App', ['restangular'])
.config(function(RestangularProvider) {
RestangularProvider.setBaseUrl('/api');
RestangularProvider.setDefaultHeaders({
"headers": { "common": { "Accept": "application/json" } }
});
})
.service('StaticsService', ['$scope', 'Restangular',
function($scope, Restangular) {
$scope.commodities = Restangular.all('commodities').getList();
@derwolfe
derwolfe / gist:7320407
Last active December 27, 2015 11:39
standalone ping check config
{
"checks": {
"ping_check": {
"handlers": ["default"],
"command": "/etc/sensu/plugins/check-http.rb -p http://www.rmienergy.com",
"interval": 5,
"standalone": true,
}
}
}
using Nancy;
using Nancy.Testing;
using Xunit;
using df_nancy.Modules.api;
namespace df_tests.ApiTests
{
public class PositionApiTests
{
[Fact]