This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import random | |
def main(): | |
#deck = [(value, color) for value in range(3) for color in range(4)] * 4 | |
#deck = [(value, color) for value in range(4) for color in range(4)] * 3 | |
x16 = [(value, color) for value in range(2) for color in range(4)] * 4 | |
x8 = [(value + 2, color) for value in range(2) for color in range(4)] * 2 | |
deck = x16 + x8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/time.h> | |
#include <glib.h> | |
#define GST_USE_UNSTABLE_API | |
#include <gst/gst.h> | |
#include <gst/rtsp-server/rtsp-server.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nhlib, nhlib.site, nhlib.calc | |
fault_mfd = nhlib.mfd.EvenlyDiscretizedMFD(min_mag=5.5, bin_width=1, | |
occurrence_rates=[0.1, 0.01, 0.001]) | |
fault_trace = nhlib.geo.Line([nhlib.geo.Point(*coords) | |
for coords in [(10, 7), (10.4, 7), (10.6, 6.8)]]) | |
fault = nhlib.source.SimpleFaultSource( | |
'f1', 'fault 1', tectonic_region_type=nhlib.const.TRT.STABLE_CONTINENTAL, | |
mfd=fault_mfd, rupture_mesh_spacing=5, rupture_aspect_ratio=1.5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from miniquake import * | |
SITES = sites(boundary=[(-111, 29), (-127, 29), (-127, 43.5), (-111, 43.5)], | |
discretization=10, vs30=760, vs30measured=False, z1pt0=100, | |
z2pt5=5) | |
SOURCES = sources('/tmp/NRML04/CaliforniaGriddedSeismicity.xml', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def missing(seq): | |
num_missing = 2 | |
for i in xrange(num_missing): | |
seq.append(None) | |
for i in xrange(len(seq) - 2): | |
if seq[i] == i: | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Reader(object): | |
def __init__(self): | |
self.buf = [] | |
self.result = [] | |
self._mode = 'keyvalue' | |
self._resdict = {} | |
self._datasize = 0 | |
self._databuf = [] | |
self._datakey = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from decimal import Decimal | |
import time | |
import multiprocessing | |
import numpy | |
from nhlib import const | |
from nhlib.site import SiteCollection | |
from nhlib.source import AreaSource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="nhlib: A New Hazard Library" | |
COPYRIGHT="Copyright (C) 2012 GEM Foundation" | |
for f in `find * -type f` ; do | |
if [ "$f" = "LICENSE" ] ; then continue; fi | |
head -n 3 $f | grep "$NAME $COPYRIGHT" --silent && \ | |
echo "- $f has license, skipping" && \ | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lines starting with symbol # are comments. | |
# On the top level each logic tree definition should have | |
# two specific items: SourceModelLogicTree and GMPELogicTree. | |
# SourceModelLogicTree node allows to specify the first level | |
# of branching: uncertainty on source model definition. | |
SourceModelLogicTree: | |
# The next line means "take source_model1.xml with chance of 1/2". | |
- 0.5: source_model1.xml |