Skip to content

Instantly share code, notes, and snippets.

@Syerram
Syerram / gist:7002597
Last active December 25, 2015 15:59
Setup for Django Presentation

Setup

Pre-requisites

  • Python 2.6 or higher - Higher version is better but 2.6 will do. You're on your own with Python 3.xx version.
    • For Windows users, see the last section
  • pip:
    • Most *nix distributions come with easy_install. To check if its installed, do which easy_install. It should list the path to the file.
    • If the above works, then run this at command line easy_install pip. [might require you to install as admin]
  • django: At command line run pip install django==1.4
  • To install it manually, especially for Windows users, see the last section.
@Syerram
Syerram / gist:7045629
Last active December 25, 2015 21:49
Django Code workshop

Coding

Startup

#creates a new folder.
$ django-admin.py startproject my_todo

$ cd my_todo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style type="text/css">
a { display:block; margin: 10px 0;}
</style>
</head>
<body>
#Snapshot of exact code at the end of the test.
#I wanted to first find all solutions to place N queen such no two queens threaten each other
#From that, I can then find a max threat
#Hardcoding due to insufficient time
N = 4
#{3,1,4, 1}
board = [
[0, 0, 1, 0],
@Syerram
Syerram / cf-dot-get-mem.sh
Last active June 26, 2019 23:55
cf dot - Get free memory after the CF upgrade
# For help on this command, please contact the Diego team on CF slack channel #diego
cfdot cell-states \
| jq '(.RootFSProviders.preloaded.set | keys) as $rootfses | select($rootfses | contains(["linux"])) | .segment = "Segment: \(.PlacementTags | .[0] // "(shared)") | Stacks: \($rootfses | join(", "))"' \
| jq '{segment, containers: (.TotalResources.Containers - .AvailableResources.Containers), total_memory: .TotalResources.MemoryMB, free_memory: .AvailableResources.MemoryMB, cells: 1}' \
| jq -s 'reduce (.[] | .segment as $s | del(.segment) | to_entries[] | .segment = $s) as $i ({}; .[$i.segment][$i.key] += $i.value) | to_entries | map(.value.segment = .key | .value) | sort_by(.segment) | .[]' \
| jq -r '(.free_memory - (.containers * 32)) as $free_memory_after | "\(.segment)\n Cells: \(.cells)\n Containers: \(.containers)\n Current Free Memory: \(.free_memory) MB / \(.free_memory / .total_memory * 1000 | floor /10)%\n Additional Memory Required: \(.containers * 32) MB\n Free Memory Afterward: \($free_memo
@Syerram
Syerram / test-failure-option-a.log
Created July 1, 2019 15:24
Test failure - Option A
• Failure [253.063 seconds]
[route_services]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:108
Route Services
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:114
when a route binds to a service
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:25
when service broker returns a route service url
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:26
a request to the app is routed through the route service [It]
@Syerram
Syerram / test-failure-option-b.log
Created July 1, 2019 15:25
Test failure - Option B
• Failure [253.063 seconds]
[route_services]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:108
Route Services
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:114
when a route binds to a service
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:25
when service broker returns a route service url
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:26
a request to the app is routed through the route service [It]
@Syerram
Syerram / test-failure-option-c.log
Created July 1, 2019 15:26
Test failure - Option C
• Failure [253.063 seconds]
[route_services]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:108
Route Services
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:114
when a route binds to a service
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:25
when service broker returns a route service url
/go/src/github.com/cloudfoundry/cf-acceptance-tests/route_services/route_services.go:26
a request to the app is routed through the route service [It]
@Syerram
Syerram / setup-failure-option-a.log
Created July 1, 2019 15:31
Setup failure - Option A
• Failure in Spec Setup (BeforeEach) [85.028 seconds]
[routing]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:164
Zipkin Tracing
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:174
when zipkin tracing is enabled [BeforeEach]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/routing/zipkin_tracing.go:44
when zipkin headers are not in the request
/go/src/github.com/cloudfoundry/cf-acceptance-tests/routing/zipkin_tracing.go:45
the sleuth error response has no error
@Syerram
Syerram / setup-failure-option-b.log
Created July 1, 2019 15:31
Setup failure - Option B
• Failure in Spec Setup (BeforeEach) [85.028 seconds]
[routing]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:164
Zipkin Tracing
/go/src/github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers/cats_suite_helpers.go:174
when zipkin tracing is enabled [BeforeEach]
/go/src/github.com/cloudfoundry/cf-acceptance-tests/routing/zipkin_tracing.go:44
when zipkin headers are not in the request
/go/src/github.com/cloudfoundry/cf-acceptance-tests/routing/zipkin_tracing.go:45
the sleuth error response has no error