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
| # inspired by https://bsky.app/profile/fritzby.bsky.social/post/3m4k67fsgi22b | |
| # and https://bsky.app/profile/radishharmers.bsky.social/post/3m4mah76u4s27 | |
| from random import random | |
| def gamble(wallet, bet_amount, walk_away_at, win_prob): | |
| while 0 < wallet < walk_away_at: | |
| wallet += bet_amount if random() < win_prob else -1 * bet_amount | |
| return 1 if wallet > 0 else 0 | |
| num_runs = 100000 |
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
| package variantspark | |
| import collection.JavaConverters._ | |
| import com.google.common.primitives.UnsignedBytes | |
| import org.apache.accumulo.core.client.{IteratorSetting, ZooKeeperInstance} | |
| import org.apache.accumulo.core.client.mapred.AccumuloInputFormat | |
| import org.apache.accumulo.core.client.mapreduce.impl.DelegationTokenStub | |
| import org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase._ | |
| import org.apache.accumulo.core.client.mapreduce.lib.impl.InputConfigurator | |
| import org.apache.accumulo.core.data.{Key, Value, Range => ARange} |
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
| // this code is in the public domain | |
| package com.newbrightidea.accumulo | |
| import java.io.IOException | |
| import java.util | |
| import org.apache.accumulo.core.data.{ByteSequence, Key, Range, Value} | |
| import org.apache.accumulo.core.iterators.{IteratorEnvironment, SortedKeyValueIterator, WrappingIterator} | |
| import scala.collection.JavaConverters._ |
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 unittest | |
| from mongoengine.base import BaseField | |
| from mongoengine.document import Document | |
| from mongoengine.fields import ListField | |
| from test import connect, disconnect | |
| class EnumField(BaseField): | |
| def __init__(self, **kwargs): | |
| super(EnumField,self).__init__(**kwargs) |
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
| typedef struct node { | |
| int v; | |
| node *prev_min; | |
| node *next; | |
| } node; | |
| typedef struct { | |
| node *head; | |
| node *tail; | |
| } min_queue; |
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 StreamHandler(SessionAwareWSHandler): | |
| @property | |
| def feed_id(self): | |
| return str(self.current_user.id) if self.current_user is not None else self.get_session_id() | |
| def _set_earliest_tile(self, timestamp): | |
| self.session.set_view_position(timestamp) | |
| self.save_session() |
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 TileServer(tornado.web.Application): | |
| def __init__(self, handlers=None, default_host="", transforms=None, | |
| wsgi=False, **settings): | |
| """ | |
| In addition to invoking the superclass constructor, initializes the per-server redis client and per-server | |
| redis pubsub handler. | |
| """ | |
| tornado.web.Application.__init__(self, handlers, default_host, transforms, wsgi, **settings) | |
| self._rc = redis.StrictRedis(**(settings.get('redis_config', {}))) # redis client: one per application | |
| self._rcps = self._rc.pubsub() # redis pubsub obj: one per application |
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
| function drop_target_enter(e) { | |
| var $dt = $(context.target_id) | |
| $dt.addClass('dt-entered'); | |
| pulse($dt, | |
| 500, | |
| 'linear', | |
| {opacity: 0.25}, | |
| {opacity: 1}, | |
| function() { | |
| return $dt.hasClass('dt-entered') == false; |
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
| name := "TCP Server Build Configuration" | |
| version := "0.1.0" | |
| scalaVersion := "2.9.1" | |
| javacOptions ++= Seq("-Xlint:unchecked") | |
| scalacOptions ++= Seq("-unchecked", "-deprecation") |