| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | package org.apache.commons.collections4.map; | |
| 18 | ||
| 19 | import java.io.IOException; | |
| 20 | import java.io.ObjectInputStream; | |
| 21 | import java.io.ObjectOutputStream; | |
| 22 | import java.io.Serializable; | |
| 23 | import java.util.Collection; | |
| 24 | import java.util.HashMap; | |
| 25 | import java.util.Iterator; | |
| 26 | import java.util.Map; | |
| 27 | import java.util.Set; | |
| 28 | import java.util.concurrent.TimeUnit; | |
| 29 | ||
| 30 | /** | |
| 31 | * Decorates a Map to evict expired entries once their expiration | |
| 32 | * time has been reached. | |
| 33 | *
 | |
| 34 | * When putting a key-value pair in the map this decorator uses a | |
| 35 | * {@link ExpirationPolicy} to determine how long the entry should remain alive | |
| 36 | * as defined by an expiration time value. | |
| 37 | *
 | |
| 38 | *
 | |
| 39 | * When accessing the mapped value for a key, its expiration time is checked, | |
| 40 | * and if it is a negative value or if it is greater than the current time, the | |
| 41 | * mapped value is returned. Otherwise, the key is removed from the decorated | |
| 42 | * map, and null is returned. | |
| 43 | *
 | |
| 44 | *
 | |
| 45 | * When invoking methods that involve accessing the entire map contents (i.e | |
| 46 | * {@link #containsKey(Object)}, {@link #entrySet()}, etc.) this decorator | |
| 47 | * removes all expired entries prior to actually completing the invocation. | |
| 48 | *
 | |
| 49 | *
 | |
| 50 | * Note that {@link PassiveExpiringMap} is not synchronized and is not | |
| 51 | * thread-safe. If you wish to use this map from multiple threads | |
| 52 | * concurrently, you must use appropriate synchronization. The simplest approach | |
| 53 | * is to wrap this map using {@link java.util.Collections#synchronizedMap(Map)}. | |
| 54 | * This class may throw exceptions when accessed by concurrent threads without | |
| 55 | * synchronization. | |
| 56 | *
 | |
| 57 | * | |
| 58 | * @param <K> the type of the keys in the map | |
| 59 | * @param <V> the type of the values in the map | |
| 60 | * @since 4.0 | |
| 61 | * @version $Id: PassiveExpiringMap.java 1503029 2013-07-14 19:09:25Z tn $ | |
| 62 | */ | |
| 63 | public class PassiveExpiringMap<K, V> | |
| 64 | extends AbstractMapDecorator<K, V> | |
| 65 | implements Serializable { | |
| 66 | ||
| 67 | /** | |
| 68 | * A {@link org.apache.commons.collections4.map.PassiveExpiringMap.ExpirationPolicy ExpirationPolicy} | |
| 69 | * that returns a expiration time that is a | |
| 70 | * constant about of time in the future from the current time. | |
| 71 | * | |
| 72 | * @param <K> the type of the keys in the map | |
| 73 | * @param <V> the type of the values in the map | |
| 74 | * @since 4.0 | |
| 75 | * @version $Id: PassiveExpiringMap.java 1503029 2013-07-14 19:09:25Z tn $ | |
| 76 | */ | |
| 77 | public static class ConstantTimeToLiveExpirationPolicy<K, V> | |
| 78 | implements ExpirationPolicy<K, V> { | |
| 79 | ||
| 80 | /** Serialization version */ | |
| 81 | private static final long serialVersionUID = 1L; | |
| 82 | ||
| 83 | /** the constant time-to-live value measured in milliseconds. */ | |
| 84 | private final long timeToLiveMillis; | |
| 85 | ||
| 86 | /** | |
| 87 | * Default constructor. Constructs a policy using a negative | |
| 88 | * time-to-live value that results in entries never expiring. | |
| 89 | */ | |
| 90 | public ConstantTimeToLiveExpirationPolicy() { | |
| 91 | this(-1L); | |
| 92 | } | |
| 93 | ||
| 94 | /** | |
| 95 | * Construct a policy with the given time-to-live constant measured in | |
| 96 | * milliseconds. A negative time-to-live value indicates entries never | |
| 97 | * expire. A zero time-to-live value indicates entries expire (nearly) | |
| 98 | * immediately. | |
| 99 | * | |
| 100 | * @param timeToLiveMillis the constant amount of time (in milliseconds) | |
| 101 | * an entry is available before it expires. A negative value | |
| 102 | * results in entries that NEVER expire. A zero value results in | |
| 103 | * entries that ALWAYS expire. | |
| 104 | */ | |
| 105 | public ConstantTimeToLiveExpirationPolicy(final long timeToLiveMillis) { | |
| 106 | super(); | |
| 107 | this.timeToLiveMillis = timeToLiveMillis; | |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * Construct a policy with the given time-to-live constant measured in | |
| 112 | * the given time unit of measure. | |
| 113 | * | |
| 114 | * @param timeToLive the constant amount of time an entry is available | |
| 115 | * before it expires. A negative value results in entries that | |
| 116 | * NEVER expire. A zero value results in entries that ALWAYS | |
| 117 | * expire. | |
| 118 | * @param timeUnit the unit of time for the timeToLive | |
| 119 | * parameter, must not be null. | |
| 120 | * @throws IllegalArgumentException if the time unit is null. | |
| 121 | */ | |
| 122 | public ConstantTimeToLiveExpirationPolicy(final long timeToLive, | |
| 123 | final TimeUnit timeUnit) { | |
| 124 | this(validateAndConvertToMillis(timeToLive, timeUnit)); | |
| 125 | } | |
| 126 | ||
| 127 | /** | |
| 128 | * Determine the expiration time for the given key-value entry. | |
| 129 | * | |
| 130 | * @param key the key for the entry (ignored). | |
| 131 | * @param value the value for the entry (ignored). | |
| 132 | * @return if {@link #timeToLiveMillis} ≥ 0, an expiration time of | |
| 133 | * {@link #timeToLiveMillis} + | |
| 134 | * {@link System#currentTimeMillis()} is returned. Otherwise, -1 | |
| 135 | * is returned indicating the entry never expires. | |
| 136 | */ | |
| 137 | public long expirationTime(final K key, final V value) { | |
| 138 |
2
1. expirationTime : changed conditional boundary → NO_COVERAGE 2. expirationTime : negated conditional → NO_COVERAGE |
if (timeToLiveMillis >= 0L) { |
| 139 | // avoid numerical overflow | |
| 140 | final long now = System.currentTimeMillis(); | |
| 141 |
3
1. expirationTime : changed conditional boundary → NO_COVERAGE 2. expirationTime : Replaced long subtraction with addition → NO_COVERAGE 3. expirationTime : negated conditional → NO_COVERAGE |
if (now > Long.MAX_VALUE - timeToLiveMillis) { |
| 142 | // expiration would be greater than Long.MAX_VALUE | |
| 143 | // never expire | |
| 144 |
1
1. expirationTime : replaced return of long value with value + 1 for org/apache/commons/collections4/map/PassiveExpiringMap$ConstantTimeToLiveExpirationPolicy::expirationTime → NO_COVERAGE |
return -1; |
| 145 | } | |
| 146 | ||
| 147 | // timeToLiveMillis in the future | |
| 148 |
2
1. expirationTime : Replaced long addition with subtraction → NO_COVERAGE 2. expirationTime : replaced return of long value with value + 1 for org/apache/commons/collections4/map/PassiveExpiringMap$ConstantTimeToLiveExpirationPolicy::expirationTime → NO_COVERAGE |
return now + timeToLiveMillis; |
| 149 | } | |
| 150 | ||
| 151 | // never expire | |
| 152 |
1
1. expirationTime : replaced return of long value with value + 1 for org/apache/commons/collections4/map/PassiveExpiringMap$ConstantTimeToLiveExpirationPolicy::expirationTime → NO_COVERAGE |
return -1L; |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 156 | /** | |
| 157 | * A policy to determine the expiration time for key-value entries. | |
| 158 | * | |
| 159 | * @param <K> the key object type. | |
| 160 | * @param <V> the value object type | |
| 161 | * @since 4.0 | |
| 162 | * @version $Id: PassiveExpiringMap.java 1503029 2013-07-14 19:09:25Z tn $ | |
| 163 | */ | |
| 164 | public static interface ExpirationPolicy<K, V> | |
| 165 | extends Serializable { | |
| 166 | ||
| 167 | /** | |
| 168 | * Determine the expiration time for the given key-value entry. | |
| 169 | * | |
| 170 | * @param key the key for the entry. | |
| 171 | * @param value the value for the entry. | |
| 172 | * @return the expiration time value measured in milliseconds. A | |
| 173 | * negative return value indicates the entry never expires. | |
| 174 | */ | |
| 175 | long expirationTime(K key, V value); | |
| 176 | } | |
| 177 | ||
| 178 | /** Serialization version */ | |
| 179 | private static final long serialVersionUID = 1L; | |
| 180 | ||
| 181 | /** | |
| 182 | * First validate the input parameters. If the parameters are valid, convert | |
| 183 | * the given time measured in the given units to the same time measured in | |
| 184 | * milliseconds. If the parameters are invalid, an | |
| 185 | * {@link IllegalArgumentException} is thrown. | |
| 186 | * | |
| 187 | * @param timeToLive the constant amount of time an entry is available | |
| 188 | * before it expires. A negative value results in entries that NEVER | |
| 189 | * expire. A zero value results in entries that ALWAYS expire. | |
| 190 | * @param timeUnit the unit of time for the timeToLive | |
| 191 | * parameter, must not be null. | |
| 192 | * @throws IllegalArgumentException if the time unit is null. | |
| 193 | */ | |
| 194 | private static long validateAndConvertToMillis(final long timeToLive, | |
| 195 | final TimeUnit timeUnit) { | |
| 196 |
1
1. validateAndConvertToMillis : negated conditional → NO_COVERAGE |
if (timeUnit == null) { |
| 197 | throw new IllegalArgumentException("Time unit must not be null"); | |
| 198 | } | |
| 199 |
1
1. validateAndConvertToMillis : replaced return of long value with value + 1 for org/apache/commons/collections4/map/PassiveExpiringMap::validateAndConvertToMillis → NO_COVERAGE |
return TimeUnit.MILLISECONDS.convert(timeToLive, timeUnit); |
| 200 | } | |
| 201 | ||
| 202 | /** map used to manage expiration times for the actual map entries. */ | |
| 203 | private final Map<Object, Long> expirationMap = new HashMap<Object, Long>(); | |
| 204 | ||
| 205 | /** the policy used to determine time-to-live values for map entries. */ | |
| 206 | private final ExpirationPolicy<K, V> expiringPolicy; | |
| 207 | ||
| 208 | /** | |
| 209 | * Default constructor. Constructs a map decorator that results in entries | |
| 210 | * NEVER expiring. | |
| 211 | */ | |
| 212 | public PassiveExpiringMap() { | |
| 213 | this(-1L); | |
| 214 | } | |
| 215 | ||
| 216 | /** | |
| 217 | * Construct a map decorator using the given expiration policy to determine | |
| 218 | * expiration times. | |
| 219 | * | |
| 220 | * @param expiringPolicy the policy used to determine expiration times of | |
| 221 | * entries as they are added. | |
| 222 | */ | |
| 223 | public PassiveExpiringMap(final ExpirationPolicy<K, V> expiringPolicy) { | |
| 224 | this(expiringPolicy, new HashMap<K, V>()); | |
| 225 | } | |
| 226 | ||
| 227 | /** | |
| 228 | * Construct a map decorator that decorates the given map and uses the given | |
| 229 | * expiration policy to determine expiration times. If there are any | |
| 230 | * elements already in the map being decorated, they will NEVER expire | |
| 231 | * unless they are replaced. | |
| 232 | * | |
| 233 | * @param expiringPolicy the policy used to determine expiration times of | |
| 234 | * entries as they are added. | |
| 235 | * @param map the map to decorate, must not be null. | |
| 236 | * @throws IllegalArgumentException if the map is null. | |
| 237 | */ | |
| 238 | public PassiveExpiringMap(final ExpirationPolicy<K, V> expiringPolicy, | |
| 239 | final Map<K, V> map) { | |
| 240 | super(map); | |
| 241 |
1
1. |
if (expiringPolicy == null) { |
| 242 | throw new IllegalArgumentException("Policy must not be null."); | |
| 243 | } | |
| 244 | this.expiringPolicy = expiringPolicy; | |
| 245 | } | |
| 246 | ||
| 247 | /** | |
| 248 | * Construct a map decorator that decorates the given map using the given | |
| 249 | * time-to-live value measured in milliseconds to create and use a | |
| 250 | * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. | |
| 251 | * | |
| 252 | * @param timeToLiveMillis the constant amount of time (in milliseconds) an | |
| 253 | * entry is available before it expires. A negative value results in | |
| 254 | * entries that NEVER expire. A zero value results in entries that | |
| 255 | * ALWAYS expire. | |
| 256 | */ | |
| 257 | public PassiveExpiringMap(final long timeToLiveMillis) { | |
| 258 | this(new ConstantTimeToLiveExpirationPolicy<K, V>(timeToLiveMillis), | |
| 259 | new HashMap<K, V>()); | |
| 260 | } | |
| 261 | ||
| 262 | /** | |
| 263 | * Construct a map decorator using the given time-to-live value measured in | |
| 264 | * milliseconds to create and use a | |
| 265 | * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. If there | |
| 266 | * are any elements already in the map being decorated, they will NEVER | |
| 267 | * expire unless they are replaced. | |
| 268 | * | |
| 269 | * @param timeToLiveMillis the constant amount of time (in milliseconds) an | |
| 270 | * entry is available before it expires. A negative value results in | |
| 271 | * entries that NEVER expire. A zero value results in entries that | |
| 272 | * ALWAYS expire. | |
| 273 | * @param map the map to decorate, must not be null. | |
| 274 | * @throws IllegalArgumentException if the map is null. | |
| 275 | */ | |
| 276 | public PassiveExpiringMap(final long timeToLiveMillis, final Map<K, V> map) { | |
| 277 | this(new ConstantTimeToLiveExpirationPolicy<K, V>(timeToLiveMillis), | |
| 278 | map); | |
| 279 | } | |
| 280 | ||
| 281 | /** | |
| 282 | * Construct a map decorator using the given time-to-live value measured in | |
| 283 | * the given time units of measure to create and use a | |
| 284 | * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. | |
| 285 | * | |
| 286 | * @param timeToLive the constant amount of time an entry is available | |
| 287 | * before it expires. A negative value results in entries that NEVER | |
| 288 | * expire. A zero value results in entries that ALWAYS expire. | |
| 289 | * @param timeUnit the unit of time for the timeToLive | |
| 290 | * parameter, must not be null. | |
| 291 | * @throws IllegalArgumentException if the time unit is null. | |
| 292 | */ | |
| 293 | public PassiveExpiringMap(final long timeToLive, final TimeUnit timeUnit) { | |
| 294 | this(validateAndConvertToMillis(timeToLive, timeUnit)); | |
| 295 | } | |
| 296 | ||
| 297 | /** | |
| 298 | * Construct a map decorator that decorates the given map using the given | |
| 299 | * time-to-live value measured in the given time units of measure to create | |
| 300 | * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. This policy | |
| 301 | * is used to determine expiration times. If there are any elements already | |
| 302 | * in the map being decorated, they will NEVER expire unless they are | |
| 303 | * replaced. | |
| 304 | * | |
| 305 | * @param timeToLive the constant amount of time an entry is available | |
| 306 | * before it expires. A negative value results in entries that NEVER | |
| 307 | * expire. A zero value results in entries that ALWAYS expire. | |
| 308 | * @param timeUnit the unit of time for the timeToLive | |
| 309 | * parameter, must not be null. | |
| 310 | * @param map the map to decorate, must not be null. | |
| 311 | * @throws IllegalArgumentException if the time unit is null. | |
| 312 | * @throws IllegalArgumentException if the map is null. | |
| 313 | */ | |
| 314 | public PassiveExpiringMap(final long timeToLive, final TimeUnit timeUnit, final Map<K, V> map) { | |
| 315 | this(validateAndConvertToMillis(timeToLive, timeUnit), map); | |
| 316 | } | |
| 317 | ||
| 318 | /** | |
| 319 | * Constructs a map decorator that decorates the given map and results in | |
| 320 | * entries NEVER expiring. If there are any elements already in the map | |
| 321 | * being decorated, they also will NEVER expire. | |
| 322 | * | |
| 323 | * @param map the map to decorate, must not be null. | |
| 324 | * @throws IllegalArgumentException if the map is null. | |
| 325 | */ | |
| 326 | public PassiveExpiringMap(final Map<K, V> map) { | |
| 327 | this(-1L, map); | |
| 328 | } | |
| 329 | ||
| 330 | /** | |
| 331 | * Normal {@link Map#clear()} behavior with the addition of clearing all | |
| 332 | * expiration entries as well. | |
| 333 | */ | |
| 334 | @Override | |
| 335 | public void clear() { | |
| 336 |
1
1. clear : removed call to org/apache/commons/collections4/map/AbstractMapDecorator::clear → NO_COVERAGE |
super.clear(); |
| 337 |
1
1. clear : removed call to java/util/Map::clear → NO_COVERAGE |
expirationMap.clear(); |
| 338 | } | |
| 339 | ||
| 340 | /** | |
| 341 | * All expired entries are removed from the map prior to determining the | |
| 342 | * contains result. | |
| 343 | * {@inheritDoc} | |
| 344 | */ | |
| 345 | @Override | |
| 346 | public boolean containsKey(final Object key) { | |
| 347 |
1
1. containsKey : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeIfExpired → NO_COVERAGE |
removeIfExpired(key, now()); |
| 348 |
1
1. containsKey : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.containsKey(key); |
| 349 | } | |
| 350 | ||
| 351 | /** | |
| 352 | * All expired entries are removed from the map prior to determining the | |
| 353 | * contains result. | |
| 354 | * {@inheritDoc} | |
| 355 | */ | |
| 356 | @Override | |
| 357 | public boolean containsValue(final Object value) { | |
| 358 |
1
1. containsValue : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 359 |
1
1. containsValue : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.containsValue(value); |
| 360 | } | |
| 361 | ||
| 362 | /** | |
| 363 | * All expired entries are removed from the map prior to returning the entry set. | |
| 364 | * {@inheritDoc} | |
| 365 | */ | |
| 366 | @Override | |
| 367 | public Set<Entry<K, V>> entrySet() { | |
| 368 |
1
1. entrySet : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 369 |
1
1. entrySet : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::entrySet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.entrySet(); |
| 370 | } | |
| 371 | ||
| 372 | /** | |
| 373 | * All expired entries are removed from the map prior to returning the entry value. | |
| 374 | * {@inheritDoc} | |
| 375 | */ | |
| 376 | @Override | |
| 377 | public V get(final Object key) { | |
| 378 |
1
1. get : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeIfExpired → NO_COVERAGE |
removeIfExpired(key, now()); |
| 379 |
1
1. get : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.get(key); |
| 380 | } | |
| 381 | ||
| 382 | /** | |
| 383 | * All expired entries are removed from the map prior to determining if it is empty. | |
| 384 | * {@inheritDoc} | |
| 385 | */ | |
| 386 | @Override | |
| 387 | public boolean isEmpty() { | |
| 388 |
1
1. isEmpty : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 389 |
1
1. isEmpty : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.isEmpty(); |
| 390 | } | |
| 391 | ||
| 392 | /** | |
| 393 | * Determines if the given expiration time is less than now. | |
| 394 | * | |
| 395 | * @param now the time in milliseconds used to compare against the | |
| 396 | * expiration time. | |
| 397 | * @param expirationTimeObject the expiration time value retrieved from | |
| 398 | * {@link #expirationMap}, can be null. | |
| 399 | * @return true if expirationTimeObject is ≥ 0 | |
| 400 | * and expirationTimeObject < now. | |
| 401 | * false otherwise. | |
| 402 | */ | |
| 403 | private boolean isExpired(final long now, final Long expirationTimeObject) { | |
| 404 |
1
1. isExpired : negated conditional → NO_COVERAGE |
if (expirationTimeObject != null) { |
| 405 | final long expirationTime = expirationTimeObject.longValue(); | |
| 406 |
5
1. isExpired : changed conditional boundary → NO_COVERAGE 2. isExpired : changed conditional boundary → NO_COVERAGE 3. isExpired : negated conditional → NO_COVERAGE 4. isExpired : negated conditional → NO_COVERAGE 5. isExpired : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return expirationTime >= 0 && now >= expirationTime; |
| 407 | } | |
| 408 |
1
1. isExpired : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 409 | } | |
| 410 | ||
| 411 | /** | |
| 412 | * All expired entries are removed from the map prior to returning the key set. | |
| 413 | * {@inheritDoc} | |
| 414 | */ | |
| 415 | @Override | |
| 416 | public Set<K> keySet() { | |
| 417 |
1
1. keySet : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 418 |
1
1. keySet : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::keySet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.keySet(); |
| 419 | } | |
| 420 | ||
| 421 | /** | |
| 422 | * The current time in milliseconds. | |
| 423 | */ | |
| 424 | private long now() { | |
| 425 |
1
1. now : replaced return of long value with value + 1 for org/apache/commons/collections4/map/PassiveExpiringMap::now → NO_COVERAGE |
return System.currentTimeMillis(); |
| 426 | } | |
| 427 | ||
| 428 | @Override | |
| 429 | public V put(final K key, final V value) { | |
| 430 |
1
1. put : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::put to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return put(key, value, now()); |
| 431 | } | |
| 432 | ||
| 433 | /** | |
| 434 | * Add the given key-value pair to this map as well as recording the entry's expiration time based on | |
| 435 | * the current time in milliseconds, now and this map's {@link #expiringPolicy}. | |
| 436 | */ | |
| 437 | private V put(final K key, final V value, final long now) { | |
| 438 | // record expiration time of new entry | |
| 439 | final long expirationTime = expiringPolicy.expirationTime(key, value); | |
| 440 | expirationMap.put(key, Long.valueOf(expirationTime)); | |
| 441 | ||
| 442 |
1
1. put : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::put to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.put(key, value); |
| 443 | } | |
| 444 | ||
| 445 | @Override | |
| 446 | public void putAll(final Map<? extends K, ? extends V> mapToCopy) { | |
| 447 |
1
1. putAll : negated conditional → NO_COVERAGE |
for (final Map.Entry<? extends K, ? extends V> entry : mapToCopy.entrySet()) { |
| 448 | put(entry.getKey(), entry.getValue()); | |
| 449 | } | |
| 450 | } | |
| 451 | ||
| 452 | /** | |
| 453 | * Normal {@link Map#remove(Object)} behavior with the addition of removing | |
| 454 | * any expiration entry as well. | |
| 455 | * {@inheritDoc} | |
| 456 | */ | |
| 457 | @Override | |
| 458 | public V remove(final Object key) { | |
| 459 | expirationMap.remove(key); | |
| 460 |
1
1. remove : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::remove to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.remove(key); |
| 461 | } | |
| 462 | ||
| 463 | /** | |
| 464 | * Removes all entries in the map whose expiration time is less than | |
| 465 | * now. The exceptions are entries with negative expiration | |
| 466 | * times; those entries are never removed. | |
| 467 | * | |
| 468 | * @see #isExpired(long, Long) | |
| 469 | */ | |
| 470 | private void removeAllExpired(final long now) { | |
| 471 | final Iterator<Map.Entry<Object, Long>> iter = expirationMap.entrySet().iterator(); | |
| 472 |
1
1. removeAllExpired : negated conditional → NO_COVERAGE |
while (iter.hasNext()) { |
| 473 | final Map.Entry<Object, Long> expirationEntry = iter.next(); | |
| 474 |
1
1. removeAllExpired : negated conditional → NO_COVERAGE |
if (isExpired(now, expirationEntry.getValue())) { |
| 475 | // remove entry from collection | |
| 476 | super.remove(expirationEntry.getKey()); | |
| 477 | // remove entry from expiration map | |
| 478 |
1
1. removeAllExpired : removed call to java/util/Iterator::remove → NO_COVERAGE |
iter.remove(); |
| 479 | } | |
| 480 | } | |
| 481 | } | |
| 482 | ||
| 483 | /** | |
| 484 | * Removes the entry with the given key if the entry's expiration time is | |
| 485 | * less than now. If the entry has a negative expiration time, | |
| 486 | * the entry is never removed. | |
| 487 | */ | |
| 488 | private void removeIfExpired(final Object key, final long now) { | |
| 489 | final Long expirationTimeObject = expirationMap.get(key); | |
| 490 |
1
1. removeIfExpired : negated conditional → NO_COVERAGE |
if (isExpired(now, expirationTimeObject)) { |
| 491 | remove(key); | |
| 492 | } | |
| 493 | } | |
| 494 | ||
| 495 | /** | |
| 496 | * All expired entries are removed from the map prior to returning the size. | |
| 497 | * {@inheritDoc} | |
| 498 | */ | |
| 499 | @Override | |
| 500 | public int size() { | |
| 501 |
1
1. size : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 502 |
1
1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.size(); |
| 503 | } | |
| 504 | ||
| 505 | /** | |
| 506 | * Read the map in using a custom routine. | |
| 507 | * | |
| 508 | * @param in the input stream | |
| 509 | * @throws IOException | |
| 510 | * @throws ClassNotFoundException | |
| 511 | */ | |
| 512 | @SuppressWarnings("unchecked") | |
| 513 | // (1) should only fail if input stream is incorrect | |
| 514 | private void readObject(final ObjectInputStream in) | |
| 515 | throws IOException, ClassNotFoundException { | |
| 516 |
1
1. readObject : removed call to java/io/ObjectInputStream::defaultReadObject → NO_COVERAGE |
in.defaultReadObject(); |
| 517 | map = (Map<K, V>) in.readObject(); // (1) | |
| 518 | } | |
| 519 | ||
| 520 | /** | |
| 521 | * Write the map out using a custom routine. | |
| 522 | * | |
| 523 | * @param out the output stream | |
| 524 | * @throws IOException | |
| 525 | */ | |
| 526 | private void writeObject(final ObjectOutputStream out) | |
| 527 | throws IOException { | |
| 528 |
1
1. writeObject : removed call to java/io/ObjectOutputStream::defaultWriteObject → NO_COVERAGE |
out.defaultWriteObject(); |
| 529 |
1
1. writeObject : removed call to java/io/ObjectOutputStream::writeObject → NO_COVERAGE |
out.writeObject(map); |
| 530 | } | |
| 531 | ||
| 532 | /** | |
| 533 | * All expired entries are removed from the map prior to returning the value collection. | |
| 534 | * {@inheritDoc} | |
| 535 | */ | |
| 536 | @Override | |
| 537 | public Collection<V> values() { | |
| 538 |
1
1. values : removed call to org/apache/commons/collections4/map/PassiveExpiringMap::removeAllExpired → NO_COVERAGE |
removeAllExpired(now()); |
| 539 |
1
1. values : mutated return of Object value for org/apache/commons/collections4/map/PassiveExpiringMap::values to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return super.values(); |
| 540 | } | |
| 541 | } | |
Mutations | ||
| 138 |
1.1 2.2 |
|
| 141 |
1.1 2.2 3.3 |
|
| 144 |
1.1 |
|
| 148 |
1.1 2.2 |
|
| 152 |
1.1 |
|
| 196 |
1.1 |
|
| 199 |
1.1 |
|
| 241 |
1.1 |
|
| 336 |
1.1 |
|
| 337 |
1.1 |
|
| 347 |
1.1 |
|
| 348 |
1.1 |
|
| 358 |
1.1 |
|
| 359 |
1.1 |
|
| 368 |
1.1 |
|
| 369 |
1.1 |
|
| 378 |
1.1 |
|
| 379 |
1.1 |
|
| 388 |
1.1 |
|
| 389 |
1.1 |
|
| 404 |
1.1 |
|
| 406 |
1.1 2.2 3.3 4.4 5.5 |
|
| 408 |
1.1 |
|
| 417 |
1.1 |
|
| 418 |
1.1 |
|
| 425 |
1.1 |
|
| 430 |
1.1 |
|
| 442 |
1.1 |
|
| 447 |
1.1 |
|
| 460 |
1.1 |
|
| 472 |
1.1 |
|
| 474 |
1.1 |
|
| 478 |
1.1 |
|
| 490 |
1.1 |
|
| 501 |
1.1 |
|
| 502 |
1.1 |
|
| 516 |
1.1 |
|
| 528 |
1.1 |
|
| 529 |
1.1 |
|
| 538 |
1.1 |
|
| 539 |
1.1 |


I FoR DeliveRy
Use tab keys to move from one input field to the next.
We Deliver For You
Order Form
Officer Pass Id :
Order Number :
Date :
(day)
1
2
3
4
more
(Month)
January
February
March
April
more
(Year)
2015
2016
2017
2018
more
Name :
Mobile Number :
Address :
ZIP Code:
Email:
Service Order :
Delivery
Pick Up
No. of Item:
(submit number of item)
1
2
3
4
more
Service Type:
Reguler
Express
Weight:
kg
Price:
Item Description:


Choose a Demo
String
Local File(s)
Remote File
JSON to CSV
Choose one or more delimited text files for Papa to parse.
Sample files:
Type the URL of the file to be downloaded and parsed.
(cross-origin requests require Access-Control-Allow-Origin header)
Sample files:
(cross-origin requests require Access-Control-Allow-Origin header)
Results will appear in the console of your browser's inspector tools


{% extends "mail/base.html" %} {% block body %}
We have received a request to change your email.
To confirm this change, please click on this link: {{ config.HOSTNAME }}/confirm/{{ user.username }}/{{ user.change_configuration.confirmation_code }}


Reconnaissance
compgen -c #list all commands that the current shell knows about
The first step should be to gather a little information. You'll need to know your environment. Run the 'env' command to understand how your profile is configured. You'll see which shell you're running and where your PATH is pointing to. Once you know what your PATH is, list the contents of the directory (i.e. 'ls /usr/local/rbin') to see which commands are present. It is possible you may not be able to run the 'ls' command. If not, you can use the 'echo' command with an asterisk to 'glob' directory contents if it's available:
echo /usr/local/rbin/*
You can continue on through the file system using this command to help you find other files and commands. Basically, you'll be armed with built-in shell commands as well as the ones listed in your PATH. This is your arsenal for attacking the restricted shell, but there may be exceptions as we'll find out. Once you know which commands you can execute, research each one of them to see if there are known shell escapes associated with them. Some of the techniques we're about to get into can be combined together.
env
export
echo $PATH
echo $SHELL
ls $PATH or start trying commands to see what programs you have access to


Lady Trieu Makes Her Debut in New Watchmen Episode 4 Stills
by Tudor LeonteHBO has release a new batch of photos for the upcoming Episode 4 of Watchmen, featuring a closer look at Hong Chau’s Lady Trieu, who will make her debut. Additionally, we see also Jeremy Irons’ The Lord keeping on with his experiments. The synopsis of the next episode of Watchmen reads as follows:
Reclusive trillionaire Lady Trieu (Hong Chau) finally enters the stage with a mysterious offer. With Blake (Jean Smart) getting closer to the truth of her coverup, Angela (Regina King) enlists Looking Glass (Tim Blake Nelson) for help. Meanwhile, The Lord (Jeremy Irons) trains two new servants.
Andrij Parekh directed the episode written by Damon Lindelof & Christal Henry. You can check the new Watchmen Episode 4 stills in the player below.
RELATED – Volume One of Trent Reznor and Atticus Ross’ Watchmen Score is Now Streaming
Set in an alternate history where “superheroes” are treated as outlaws, Watchmen embraces the nostalgia of the original groundbreaking graphic novel while attempting to break new ground of its own. Originally published as a 12-issue miniseries beginning in 1986, Watchmen quickly become one of sequential art’s most acclaimed stories. The original story centers on a murder-mystery before unfolding into a planet-altering conspiracy that ultimately asks where the fine line is drawn between heroes and villains.
Lindelof serves as creator, writer, showrunner, and executive producer on the Watchmen series, with Tom Spezialy, Stephen Williams, and Joseph Iberti also executive producing. In addition to directing the pilot, Nicole Kassell will executive produce. The series comes from Lindelof’s White Rabbit in association with Warner Bros. Television and is based on the DC Comics characters.
The next episode of Watchmen airs November 10. What do you think Lady Trieu will impact the story? Let us know in the comments section below.


Find Perfect
House From Your Area.
From as low as $20 A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
${{ property.price | intcomma }}
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia.
A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth.
On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their.
{{tm.description}}
{{ tm.client }}
{{ tm.client_status }}Listing {{seller.num_prop }} Properties


THANK YOU FOR REGISTERING!
YOU WILL RECEIVE A VERIFICATION EMAIL ON THE EMAIL ID YOU PROVIDED WITHIN THE NEXT 12 HOURS.


things & stuff
Why, hello there! Welcome to my list of things. Click or tap the button to a thing to the list. Click or tap a thing's label to rename it. Type some text in the input to filter things by name.
New thing
|
{{task.name}}
{{task.timeString}}
Label
Compensation
Drink a beer after completing this.


Since beginning my journey as a designer nearly 3 years ago, I've done remote work for agencies, consulted for startups, and collaborated with talented people to create digital products for both business and consumer use. I'm quietly confident, naturally curious, and perpetually working on improving my chops one design problem at a time.
A front-end developer's role is to combine design and business logic to achieve a user-facing product. To do this successfully, a wide skill set is necessary to produce a quality user experience that leads to meeting business goals. With my experience I can:
I'm proﬁcient with Adobe Photoshop, XD and illustrator. My expertise are Web Designing, UI/UX Designing, Logo and Branding. I have theability to comfortably brainstorm with the clients, grasp their vision and turn it into reality.
I like to code things from scratch, and enjoy bringing ideas to life in the browser.I've extended experience in converting PSDs to HTML, Since I come from a design background I understand entirely what pixel-perfect mockups. I assure you that the work quality will be according to the modern standard and the browser compatible testing is done. After the completion of the project, I will run the speed optimizations and follow the w3 HTML5 stands.
Build Design using theme builder (DIVI, Avada, Fusion Builder, Wp Bakery, The 7 etc)
WordPress UNISON Framework (Theme Options, Component)
Custom WordPress Theme creation (ACF Plugin).
WordPress Customization.
WordPress Payment integration
WooCommerce
A front-end developer's role is to combine design and business logic to achieve a user-facing product. To do this successfully, a wide skill set is necessary to produce a quality user experience that leads to meeting business goals. With my experience I can:


Lets try it !
This page demonstrates creation of block indexes on the second fact table.
Operation
- Create table 'subscriber_dedicated_account_usage_mdc' enabled with Multi-Dimensional Clustering
- Populate data into the table. Data is clustered along multiple dimensions depending on the clustering columns specified.
Best Practices
- Start your selection for MDC candidates by looking for columns that are used as predicates for equality, inequality, range, and sorting.
- Strive for density! Remember, an extent is allocated for every existing cell regardless of the number of rows in that cell. To leverage MDC with optimal
space utilization, strive for densely filled blocks.
- Constrain the number of cells in an MDC design to limit how much additional storage the table will require when converted to MDC form. 5% to 10% growth for any single table is a reasonable goal.
- Don't select too many dimensions. The more the dimensions, more exponential the increase in the cardinality of cells not only requiring more storage, but the gains of clustering might be lost due to the increase in doing I/O on partially filled blocks.


DCU Dashboard
Timetable
{% for day in modulesPerDay %}
{% endfor %}
{% endfor %}
{{day.day}}
{% for i in day.data %}{{i.module}} {{i.duration}}h
{{i.start_hour}}:{{i.start_min}} - {{i.end_hour}}:{{i.end_min}}
Today you have {{lectureCount.count}} lectures today
{% if lectureCount.count > 0 %}and you will start at
{{lectureCount.first.hour}}:{{lectureCount.first.min}}.{% endif %}
Announcements
{% for ann in announcements %}
{% endfor %}
{{ann.module}}
{{ann.info}}{% endfor %}
Book rental
You have no due books.


Our aim is to power up progressive organizing technology by dramatically improving user experience and, as a result, deepening civic engagement through joyful collaboration and convivial competition.

Engaging and welcoming interactions.
Our uniqueness makes us stronger.
Active & knowledgeable community.
Motivate and reinforce our users.
Give direction and purpose.


The Simplest Blog Ever
This is a list of all of the notebooks that I have published:
Multi-Armed Bandit


--- layout: null title: Examples Prism keywords: Prism, Syntax highlight description: prism.js and "Line Numbers" plugins demo ---
The examples in this page serve a dual purpose: They act as unit tests, making it easy to spot bugs, and at the same time demonstrate what Prism can do, on simple and on edge cases.
To use this language, use the class "language-cpp"

hi!

"foo \"bar\" baz"
'foo \'bar\' baz'
"Multi-line strings ending with a \
are supported too."
# include <stdio.h>
#define PG_locked 0
#define PG_error 1
true;
false;
a and b;
c bitand d;
/*
David Cary 2010-09-14
quick demo for wikibooks
public domain
*/
#include <iostream>
#include <vector>
using namespace std;
vector<int> pick_vector_with_biggest_fifth_element(
vector<int> left,
vector<int> right
){
if( (left[5]) < (right[5]) ){
return( right );
};
// else
return( left );
}
int vector_demo(void){
cout << "vector demo" << endl;
vector<int> left(7);
vector<int> right(7);
left[5] = 7;
right[5] = 8;
cout << left[5] << endl;
cout << right[5] << endl;
vector<int> biggest(
pick_vector_with_biggest_fifth_element( left, right )
);
cout << biggest[5] << endl;
return 0;
}
int main(void){
vector_demo();
}
#include <stdio.h>
main(int argc, char *argv[])
{
int c;
printf("Number of command line arguments passed: %d\n", argc);
for ( c = 0 ; c < argc ; c++)
printf("%d. Command line argument passed is %s\n", c+1, argv[c]);
return 0;
}


Apple CEO Tim Cook's pressing the flesh in Japan
Source: Apple
What you need to know
- Apple CEO Tim Cook is in Japan right now.
- He's been meeting Apple Store employees and app developers.
- Cook is sharing photo ops via Twitter.
Apple CEO Tim Cook is currently in Japan meeting developers and members of Apple Store teams. He's also been sharing the highlights of his visit on Twitter, complete with well-staged photos.
Cook has been known to travel the world as part of his role as the head of one of the planet's biggest companies and he recently visited the likes of France and Germany.
During this trip in particular Cook met developers at Apple Omotesando, while also sharing a great photo of Tokyo that was, obviously, #shotoniPhone.
Save 40% and get three months of wireless service for just $45
Cook also took the oportunity to meet with people working in the healthcare field during a visit to Keio University School of Medicine.
Cook's visit happened to coincide with Computer Science Education Week, with students learning about coding at Apple Marunouchi.
You can see more photos of Cook's trip on his official Twitter account.
We may earn a commission for purchases using our links. Learn more.


This file provides a detailed description of the methods, parameters and properties of the VMRC API implemented by vCloud Director 1.5.
Value: application/x-vmware-remote-console-2011-1
Used to load the plugin in Firefox.
Value: CLSID:A24C4C22-E2B7-4701-9DF1-E51BDC809850
Used to load the plugin in Internet Explorer.
The following property values are exposed by the VMRC API and should be retrieved and used as appropriate when invoking API methods or interpreting event callback parameters.
Values:
VMRC_MKS
VMRC_DEVICES
Specified at startup() time to indicate the mode of the VMRC plugin instance for the lifetime of its connection.
A plugin may operate in either MKS mode where guest screen contents are displayed and the user can interact with the guest, or DEVICES mode in order to connect/disconnect remote device backings to/from virtual machine devices.
Currently VMRC_MKS is the only supported value.
Values:
VMRC_EVENT_MESSAGES
Specified at startup() time to indicate the mode by which messages are delivered from the plugin to its container.
Currently VMRC_EVENT_MESSAGES is the only supported value.
Values:
VMRC_MESSAGE_INFO
VMRC_MESSAGE_WARNING
VMRC_MESSAGE_ERROR
VMRC_MESSAGE_HINT
Indicates the type of message delivered to the onMessage() event handler.
Values:
VMRC_CS_DISCONNECTED
VMRC_CS_CONNECTED
Specifies the connection state to the onConnectionState() event handler.
Values:
VMRC_GS_GRABBED
VMRC_GS_UNGRABBED_HARD
VMRC_GS_UNGRABBED_SOFT
Specifies the active grab type to the onGrabState() event handler.
In a soft-ungrab state, input will be redirected to the guest once the user mouses over the guest window.
The following events are generated by the VMRC API.
Invoked in response to connection state changes.
Handler parameters:
connection state, one of VMRC_CS_DISCONNECTED or VMRC_CS_CONNECTED
remote hostname of connection
VM id/reference for connection
was this connection state requested by the user?
further information on what took place
Invoked in response to changes in the guest screen size.
Handler parameters:
new width of guest screen
new height of guest screen
Invoked in response to changes in the plugin fullscreen state.
Handler parameters:
new fullscreen state (true → plugin has switched to fullscreen)
Invoked in response to changes in the plugin grab state.
Handler parameters:
new grab state
Invoked in response to a new message generated by the plugin.
Handler parameters:
type of message
message content
The following methods are provided by the VMRC API.
Indicates whether the plugin has loaded and is ready to be started.
Returns: [boolean]
if startup() can be called
if not
Must be invoked prior to connect() in order to initialize the plugin.

Returns: [boolean]
on success
on failure
Connect the plugin instance to a remote host.
Parameters:
hostname/IP of remote host provided by VMware vCloud Director API
screen ticket provided by VMware vCloud Director API
vm ID provided by VMware vCloud Director API
internal use, must be the empty string ("")
Returns: [boolean]
on success
on failure
Disconnect the plugin instance from a remote host.
Returns: [boolean]
on success
on failure
Retrieve current connection state.
Returns: [VMRC_ConnectionState]
if the plugin is connected
if the plugin is not connected
Retrieve current screen width.
Returns: [int]
Retrieve current screen height.
Returns: [int]
Instruct the plugin to enter/exit fullscreen mode.
Parameters:
true to enter fullscreen mode, false to exit
Returns: [boolean]
on success
on failure
Instruct the plugin to deliver a Control-Alt-Delete key sequence to the guest.
Returns: [boolean]
on success
on failure
Retrieve a string representing the current complete version number of the installed VMRC Plugin.
Returns: [string] VMRC plugin full version number
Retrieve an array of supported APIs. See example:getSupportedApi().
Returns: [string[]] array indicating supported API strings, e.g. "vsphere-2011"


{% extends 'layout.html' %} {% block body %}
I have no photos sorry
CONTACT ON EMAIL : {{ photographer.email }}
CONTACT ON PHONE : {{ photographer.phone_number }}
{{ photo.name }}


Get a model from the grid collection, specified by an id or by passing in a model.
obj
(object), (integer)
- Data model or id value for the model to get.
(object)
- A data model object.
// Get by id
new DobyGrid(...).get(5);
// Get by model reference
new DobyGrid(...).get({id: 23, name: 'bob', age: 75});


Exploration in Engineering
Below is a link to connect to the other part of my website
https://18alnewman.wixsite.com/mysite


YOUTUBE VIDEO DOWNLOADER
DOWNLOAD ANY PUBLIC VIDEO
Download
Loading...
✓
Download is complete! The file will be removed in 30 minutes.
Download
Restart
Logo GIF
from
Logo GIFs


I have suffered from insomnia for years. I remember as far back as when I was in the second grade I would stay up nights all the time, usually I would just lie in bed and try to sleep, because my parents wouldn't let me take any pills for my problem.
Once in the fifth grade I found two 10 mg zolpidem (Ambien) pills in my father's medicine cabinet. I looked them up and, upon discovering that they were sleeping pills, took them that night and had my first 'psychedelic' experience. In retrospect it was nothing like a full-blown trip on acid or some other strong psychedelic, but at the time it was amazing: I listened to an audiobook and watched the characters act out scenes on my bed as I lay in it, and every once in a while I'd see a cartoonish figure walking around in my room, furniture melted, and the ceiling sunk slowly toward my face every time I stared at it for a minute. I knew that none of this was real, and I enjoyed the experience immensely. From then on I craved zolpidem, both because I still suffered from insomnia and because it was fun.
Much more recently (a few years ago) I finally managed to persuade my parents to take me to various doctors and shrinks to discuss my insomnia with them.  Eat this! Go to bed at this time! Melatonin, Benadryl!') I finally managed to secure a prescription for zaleplon (Sonata), a drug very similar in effect (at least in my experience) to zolpidem, but whose effects are shorter in duration and, at the same dosage, generally less interesting.
I say 'generally' here because I had some amazing experiences with zaleplon during this period. The recommended dose did little even when I first tried it, but a good 50 mg is usually enough for a fun, relaxed, and very visual trip.
By now I had tried various other psychedelics, and I believe that it was these which caused the visual experiences I have with the three 'Z's to change: no longer do I see figures and realistic images with any of these drugs. Instead, the visuals generally consist of 'layering': a two-dimensional image, such as a computer monitor, a painting, or a pattern in wallpaper or on a rug, may appear three-dimensional and move without any notable change in coloration or detail, this seems to result from an alteration in the way afterimages are perceived when they overlap with various objects in my field of vision. The plainer an image or surface is, the less likely it is that it will produce visual effects. For me, this is very unlike the psychedelics which work by selectively activating 5HT2 receptors for me, since with most of them (psilocybin, LSD, 2c-i, 2c-e, mescaline, 2c-t-2, 5-MeO-DMT, blah, blah, blah) I see complex patterns even in total darkness.
The three 'Z's are zolpidem, zopiclone, and zaleplon, and I ended up trying them all. Each selectively activates certain GABA receptor subtypes (I can't remember which), thus, they produce 'reverse trips': perceptual distortions that in some ways mirror those produced by other psychedelics even though their mechanisms of action are quite different from those of other psychedelics.
Zopiclone (Lunesta in the U.S.) is my least-favorite of the three: its duration of effect grows substantially with an increase in dosage, and this surprised me very unpleasantly several times when I took three or four pills in a night only to watch the walls bend all day the next day. Normally I wouldn't be bothered by this, but each time it was accompanied by a feeling of slowness and stupidity and a tendency to act rashly and get angry over silly things, which isn't something I normally do. Zopiclone also produced, in my opinion, the least-interesting visuals.
I recently (finally) switched to ambien. I hoard up a few pills over a few days so that I never run out of pills before the script can be refilled, and when I feel like it I trip out on them. My usual dosage is three pills, but I sometimes take only one, or even a half, and I have taken eight at once in the past. Three or four is usually the optimal dose for me because I feel the peak effects the longest, the visuals are the most intense, and (importantly) I can at least vaguely remember what I did while I was on it. With 50 or 60, it gets pretty hazy, and although I've never done anything dangerous during a blackout, I find them downright creepy.
Some fun combinations: Once a friend acquired several hits of what he believed to be STP (DOM). I have no idea whether that was actually what was in this blotter, but two hours after two hits I wasn't feeling much and so I decided to hit some ambien. I took 30 mg and within twenty minutes I had cool visuals where colors seemed to melt out of objects but leave their outlines intact.
The three 'Z's always mix well together, but be careful dosing the zopiclone. Other than that, nothing else really stands out. Taking a strong psychedelic like 2c-e or LSD with any of these pills is fun, but not so fun that I do it that often. The effects of one substance alone are often greater than the effects of combining them in some instances.
Oh, and by the way--I'm a smoker, and you might be, too. If you can, avoid smoking just before and during your trip on these drugs, it can reduce or even eliminate their effects, especially if you're on zaleplon.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


FlightSurety
Operational Status
Operational Status
true
Available Flights
#
Flight Name
Flight Time
Airline
Check Flights Status
Submit to Oracles
Buy Flights Insurance
Ether
Buy
Withdraw Balance
Wallet Balance : 0
Withdraw Balance


NCSU Open Source Geospatial Research and Education Laboratory Center for Geospatial Analytics and Department of Marine, Earth and Atmospheric Sciences North Carolina State University


EJScreen Demo
This open source project replicates most of the functionality of the EPA's EJSCREEN mapping tool with an updated look and feel. It also provides machine readable access to the underlying data through a REST API.
Original Tool
The core feature set and underlying data for this project were sourced from the Environmental Justice Screening and Mapping Tool. To learm more about the original tool and how it was made, visit the EPA's website.
API Docs
COMING SOON: In order to provide clearer guidance on how to access the underlying data for this demo in a machine readable format, we are in the process of documenting our REST API using the OpenAPI Specification
Source Code
This tool and the code that powers it are open source. To ask us a question, contribute to the project, or just learn more about how it was implemented, please visit the project repository on GitHub.


More than a few Bones to Pick The Bone Collector
By Ross Anthony
Yes, it's thrilling, suspenseful and at times even bone-chilling. One woman's scream becomes a crying siren of emergency vehicles rushing to save her from being boiled alive. That's an effective scene change. In fact, "The Bone Collector" is a pretty good movie right up to the end where it makes a clean break into not being a very good movie -- fractured, as it were, in several places.
The on and off Denzel, is more on in this movie than off while Jolie is simply radiant. Denzel plays a paralyzed homicide investigator for whom the rookie cop Jolie becomes the eyes, ears and body. There's a killer loose, he's leaving all kinds of TV movie clues for Denzel to decode. The production, direction and acting work as a team to keep this film alive and kicking; unfortunately the poorly scripted climax overwhelms them all with stale anti-drama and ultimately leaves the picture itself somewhat hog-tied and whimpering.
The Bone Collector. Copyright © 1999. Rated R. Starring Denzel Washington and Angelina Jolie, Queen Latifah. Directed by Phillip Noyce. Screenplay by Jeremy Iacone. Produced by Martin Bregman, Louis A. Stroller, Michael Bregman at Universal/Columbia
Grade..........................B -- Copyright © 1999 Ross Anthony, currently based in Los Angeles, has scripted and shot documentaries, music videos, and shorts in 35 countries across North America, Europe, Africa and Asia. For more reviews visit: http://RossAnthony.com
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


The machine stops
Letter template
Letter template with tables
No content
List
Ordered list
Reversed ordered list
Long paragraph
Table
Uneven table
Table with caption
Table with no thead
Text node
Text with inline
Text with line breaks
Inline blocks
Inline break inside avoid
Break inside avoid blocks
Text with image
Text with floats
Orphans
Widows
Break before page
Break before avoid
Break after page
Break inside avoid
Break inside avoid inherited
Breaks between siblings
No possible breakpoint
Text margin, border and padding
Block margin
Break word
Relax rule 3
Relax rule 1 and 3
Relax rule 1, 2 and 3
Relax rule 1, 2, 3 and 4
Headers
Footers
Oversized last headers and footers
Oversized last headers and footers with no break


Before Change
labels = sorted(labels)
pinfo["edgecolor"] = pinfo.pop("color", "/")
pinfo["color"] = pinfo.pop("fill", "/")
ax.bar(indentation, weights, width, **pinfo)
ax.autoscale()
ax.set_xticks(indentation+width/2)
After Change
// mapped coloring aesthetics are required in ascending order acc. x
for ae in ("edgecolor", "facecolor"):
if isinstance(pinfo[ae], list):
pinfo[ae] = [color for _, color in
sorted(set(zip(x, pinfo[ae])))]
ax.bar(indentation, weights, width, **pinfo)
ax.autoscale()
ax.set_xticks(indentation+width/2)


\include{file}
The \include command is used in conjunction with the \includeonly command for selective inclusion of files. The file argument is the first name of a file, denoting file.tex. If the file is also in the file list of the \includeonly command or if there is no \includeonly command, the \include command is equivalent to
\clearpage \input{file} \clearpage
except that if the file file.tex does not exist, then a warning message rather than an error is produced. If the file is not in the file list, the \include command is equivalent to \clearpage.
The \include command may not appear in the preamble or in a file read by another \include command.
See also Splitting the Input
See also \input
Return to the LaTeX Table of Contents


---
layout: definitions
---
Let $I\subseteq\mathbb{R}^n$ be a box, $P$ a partition of $I$, $J$ the indexing set of $P$, and let $f:I\to\mathbb{R}$ be a function. For each $\vec{\alpha}\in J$, choose a point $\vec{x}^{\vec{\alpha}}\in I^{(\vec{\alpha})}$. We define the Riemann sum of $f$ with respect to the partition $P$ as
$$\begin{align*}
S(f, P):=\sum_{\vec{\alpha}\in J}f(\vec{x}^{(\vec{\alpha})})\mu(I^{(\vec{\alpha})})
\end{align*}$$
Concepts
Coming soon
Used In
Coming soon
Hypothesis
Coming soon
Results
Coming soon
Related
Coming soon


Politics & Law (Mostly American)
- ISIL Educational Pamphlet Series
- It's 1995, do you know where your Sovereignty is?
- Tyranny Page: It Can't Happen Here?
- The World Citizen Web
- You gotta fight for your right to party, even here in hyperspace. These great folks do the dirty work:
Electronic Frontier Foundation- American Civil Liberties Union
- Charlotte's Web: Government Reform Resources
- CTHEORY - An international, electronic review of books on theory, technology and culture.
- Patriots - Decide for yourself
- Ross Perot's astroturf movement: United We Stand America
- The Speed Trap Registry
- Project Vote Smart - Keeping track of your representative's voting record, campaign contributions and more. POWER TO THE PEOPLE!
- Simple CIABASE search - CIA(data)BASE focuses on CIA activities
- Love Teachings Of Kuma Sutra - Know the Law.
- The Federal Government
- Federal Register Office
- Supreme Court Decisions WWW (1990's)
- C-SPAN Gopher (House and Senate TV)
- Thomas: Congressional Legislation
- Code of Federal Regulations
- U.S. Code Gopher
- Hypertext U.S. Code
- U.S.Tax Code On-Line
- Uniform Commercial Code
- Ominousities
- 21 USC 853. Criminal forfeitures
- The Secret Service Wall of Shame
- Holocaust at Waco
- Iran-Contra, Inslaw, BNL, CIA vs. Guatemala
- MK-ULTRA - Feds secretly dose Citizens with LSD!
- DOE Office of Human Radiation Experiments Home Page
- Wedge: The Secret War between the FBI and CIA
- The biggest banking scandal: Current U.S. National Debt
- They Glorified the Killing of Indigenous People
- Theft of Hawaii
- COINTELPRO
- US Domestic Covert Operations: How COINTELPRO Helped Destroy the Movements of the 1960s
- COINTELPRO Revisited - Spying & Disruption
- The 1960s and COINTELPRO: In Defense of Paranoia
- Domestic Political Repression
- Death to Druggies and the FBI connection
- The Black Panther Party and its Annihilation by COINTELPRO
- COINTELPRO and Democracy
- COINTELPRO Documents
- COINTELPRO Document Archive (.gz)
- Reading List on Intelligence Agencies and Political Repression
- The Hidden Govenment War on Animal Activists: Includes tactics for dealing with possible informants/infiltrators
- Welcome to Spookland: Tricks of the Trade of the CIA
- The Impact of McCarthyism
- The Federal Web Locator
- U.S. Government Resources
- Propaganda Analysis Home Page
- Noam Chomsky
- Legal Information Institute
- Wile E. Coyote Vs. The Acme Company
- The Acme Company Vs. Wile E. Coyote
- Let's burn the flag
- Let's not burn the flag
- This is not a flag, burning
- STUPIDITY of the Government


This drug can be useful for withdrawing from opiates or as an alternative to street heroin or other opiates. I feel my own experiences could provide solidarity perhaps for other users who have tipped the balance of sensibility... OK, now for my History:
I have been continally prescribed 12 mg per day of buprenorphine (subutex) as an alternative to methadone or a street heroin addiction for the last three years, before which I was a heroin addict for one and a half years. For the first year or so I just took 4mg per day sublingually and found that this held me, i.e.- stopped me from feeling withdrawal symptoms, for between 24-30 hours per dose. During this time, I discovered that although Buprenorphine did inhibit the effects of opiates, this greatly depended upon the dose; the individual, and the time elapsed after taking the dose. Simply, the higher the dose taken, the more effective at blocking other opiates for longer.
I am sure that it could be considered `dangerous` for people to take benzodiazepines with buprenorphine, but I have taken large amounts of each, on many occasions, as have many people I know, and experienced nothing worse than the usual sedating effects of the benzos. If you have no tolerance to Opiates or Buprenorphine, it could be dangerous for people who aren`t used to it to mix it with too many benzos.
Amyway, onto a much more previously unmentioned subject, is the intravenous use of buprenorphine. I was injecting 12mg of Bup three times a day for a few weeks (before I went back on smack to stop fucking myself up, and now I have been on 4 x 2mg hits a day for about three months, but, hey!!), and found that it makes my veins very unelastic, hence I rapidly discovered the best way to prepare this drug for injection to minimalise bodily harm, although it is NEVER harmless to inject this stuff.
Anyway, as follows I:
1) place the appropriate dose of subutex or bup in my nice clean spoon.
2) Add the correct amount of water so that I will be able to hit up in the appropriate quantity in one go, and then mix well with, preferably, the cap of a sterile works until I can feel no crumbs or grains in the spoon, within reason.
3) LEAVE FOR AT LEAST HALF AN HOUR for the impurities to settle, or as long as I can, then
4) Get a clean filter, from a straight or a filter tip for a home-made, and cut a thinnish slice off it as I would a Swiss roll, so I still have a full width bit, but not too long.
5) Drop this widthways into the centre of the spoon, so that the fibres run horizontally, and then proceed to slowly and carefully draw up the liquid through the filter. I should find that most of the impurities stay at the base of the spoon.
6) Whilst Intravenous injection is certainly not good for me, injecting into skin or muscles has been shown to lead to a high chance of developing abscesses on those sites. I have injected this stuff, foolishly, a great deal intravenously, missed a few times, but never had an abscess, although, it is bad for my overall circulation, veins, and spare a thought for the kidneys.
It`s usually only worth doing if I'm so ill withdrawing from opiates then it can`t get any worse, but everythings relative and everybody`s different, so hey, this is my contribution anyway.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


In this page, you will find the syntax, modules and most common how to’s of Python programming language. This might be helpful for you to find python syntax and code quickly in a single web page. Click on any of the contents in the sidebar to view the python code.
Note: If you are new to programming, learning Python is the best way to start. Because, Python is easier to learn than any other programming language out there as it is concise, expressive, productive, has larger community, has rich set of libraries, frameworks and requires less time to write code.
Update: As Python2 faces end of life, the below code only supports Python3.
Basics
Hello Worldcode
1 2 3 4 5 6 7 | print("Hello World") # prints "Hello World" # above line is a comment ''' This is a multi-line comment in python ''' |
Data typescode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # declare an integer a = 12 print(a) # prints "12" print(type(a)) # prints <type 'int'> # declare a float b = 1.7 print(b) # prints "1.7" print(type(b)) # prints <type 'float'> # declare a string c = "Python" print(c) # prints "Python" print(type(c)) # prints <type 'str'> # declare a boolean d = True print(d) # prints "True" print(type(d)) # prints <type 'bool'> |
Multiple variable assignmentscode
1 2 3 4 5 6 7 8 9 | # assign values to multiple variables in a single line a, b, c = 1, 2, 3 # assign values with different data types to multiple variables in a single line a, b, c = 1, 3.5, "hello" print(type(a)) # prints <type 'int'> print(type(b)) # prints <type 'float'> print(type(c)) # prints <type 'str'> |
Math operationscode
1 2 3 4 5 6 7 | a = 10 print(a + 1) # Addition: prints "11" print(a - 1) # Subtraction: prints "9" print(a * 2) # Multiplication: prints "20" print(a / 2) # Division: prints "5" print(a ** 2) # Exponentiation: prints "100" |
Logical operationscode
1 2 3 4 5 6 7 8 | # declare some boolean variables x = True y = False print(x and y) # prints "False" print(x or y) # prints "True" print(not x) # prints "False" print(x & y) # prints "False" |
Conditionscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # if-elif-else statements import random a = [50, 100, 200, 300] # pick a random number from the list "a" b = random.choice(a) # the conditionals if (b < 100): print("Number - " + str(b) + " is less than 100") elif (b >= 100 and b < 200): print("Number - " + str(b) + " is greater than or equal to 100 but less than 200") else: print("Number -" + str(b) + " is greater than or equal to 200") # for me it prints # Number - 100 is greater than or equal to 100 but less than 200 |
Loopscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # while loop c = 0 while (c < 10): print(c, end='') c += 1 # prints<PHONE_NUMBER> # for loop numbers = [1, 2, 4] for x in numbers: print(x) # prints 1 # 2 # 4 x = 5 for c in range(x): print(c) # prints 0 # 1 # 2 # 3 # 4 |
Stringscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # declare two strings a = "Python" b = " is awesome!" print(len(a)) # Length of the string: prints "6" print(len(b)) # prints "12" print(a + b) # String concatenation: prints "Python is awesome!" print(a, b) # prints "Python is awesome!" print("{}{}".format(a, b)) # prints "Python is awesome!" print("%s%s" % (a, b)) # sprintf style formatting: prints "Python is awesome!" print(a.upper()) # converts all characters to uppercase: prints "PYTHON" print(a.lower()) # converts all characters to lowercase: prints "python" print(b.strip()) # removes trailing and leading whitespaces: prints "is awesome!" print(b.replace("awesome", "great")) # replace a substring with a new string: prints " is great!" |
Listscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # declare a list l = [1,2,3,4,5] # length of list print(len(l)) # prints "5" # indexing print(l[0]) # prints "1" print(l[1]) # prints "2" print(l[len(l)-1]) # prints "5" print(l[-1]) # negative indexing: prints "5" # insert and remove l.append(6) # inserts "6" at last print(l) # prints "[1,2,3,4,5,6]" item = l.pop() # removes last element and returns that element print(item) # prints "6" l.append("string") # adds different data type too print(l) # prints "[1,2,3,4,5,'string']" l.pop() # removes last string element # slicing list print(l[1:2]) # prints "2" print(l[1:3]) # prints "2,3" print(l[0:]) # prints "[1,2,3,4,5,'string']" print(l[0:-1]) # prints "[1,2,3,4,5]" print(l[:]) # prints "[1,2,3,4,5,'string']" # loop over the list for item in l: print(item) # prints each item in list one by one # enumerate over the list for i, item in enumerate(l): print("{}-{}".format(i, item)) # prints each item with its index # squaring elements in a list for item in l: if item%2 == 0: print(item2) # square each even number in the list # above can be achieved using a list comprehension too! (one-line) print([x2 for x in l if x%2==0]) # sort the list b = [5, 7, 2, 4, 9] # ascending order b.sort() print(b) # prints [2, 4, 5, 7, 9] # descending order b.sort(reverse=True) print(b) # prints [9, 7, 5, 4, 2] # reverse the list (notice this is not descending order sort) a = ["dhoni", "sachin", "warner", "abd"] a.reverse() print(a) # prints ['abd', 'warner', 'sachin', 'dhoni'] # count of object in list a = [66, 55, 44, 22, 11, 55, 22] print(a.count(22)) # prints 2 |
Tuplescode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # declare a tuple t = (500, 200) print(type(t)) # prints "<type 'tuple'>" print(t[1]) # prints 200 # tuple of tuples tt = ((200,100), t) print(tt) # prints "((200, 100), (500, 200))" print(tt[1]) # prints "(500, 200)" # loop over tuple for item in t: print(item) # prints each item in the tuple # built-in tuple commands print(len(t)) # prints the length of tuple which is 2 print(max(t)) # prints the max-valued element which is 500 print(min(t)) # prints the min-valued element which is 200 # convert list to tuple l = [400, 800, 1200] l_to_t = tuple(l) print(type(l_to_t)) # prints <class 'tuple'> |
Setcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # set is a collection of unordered and unindexed data which is written with curly brackets. s = {"ironman", "hulk", "thor", "thanos"} for x in s: print(x) ''' prints ironman thor hulk thanos ''' # check if value exist in set if "thanos" in s: print("endgame") # prints 'endgame' # add a single item to a set using 'add' s.add("rocket") # add multiple items to a set using 'update' s.update(["blackhood", "blackwidow"]) # get length of a set print(len(s)) # prints 7 # 'remove' or 'discard' an item from the set # 'remove' raise an error if item to remove does not exist # 'discard' will not raise any error if item to remove does not exist s.remove("thanos") s.discard("blackwidow") # clear the set s.clear() # delete the set del s |
Dictionariescode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # declare a dictionary d = { "1" : "Ironman", "2" : "Captain America", "3" : "Thor" } print(type(d)) # prints "<type 'dict'>" print(d["1"]) # prints "Ironman" # loop over dictionary for key in d: print(key) # prints each key in d print(d[key]) # prints value of each key in d (unsorted) # change values in the dictionary d["2"] = "Hulk" for key, value in d.items(): print(key + " - " + value) ''' prints 1 - Ironman 2 - Hulk 3 - Thor ''' # check if key exists in a dictionary if "3" in d: print("Yes! 3 is " + d["3"]) # prints 'Yes! 3 is Thor' # get length of the dictionary print(len(d)) # prints 3 # insert a key-value pair to a dictionary d["4"] = "Thanos" # remove a key-value pair from the dictionary d.pop("4") # same thing using 'del' keyword del d["2"] # clear a dictionary d.clear() |
Exception Handlingcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # try-except-finally # try: test a block of code for errors. # except: allows handling of errors. # finally: execute code, regardless of the result of try and except blocks. try: print(x) except: print("Something is wrong!") # prints 'Something is wrong!' as x is not defined try: print(x) except: print("Something is wrong!") finally: print("Finally always execute after try-except.") # prints # Something is wrong! # Finally always execute after try-except. |
Functionscode
1 2 3 4 | def squared(x): return x*x print(squared(2)) # prints "4" |
Intermediate
List Comprehensionscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | nums = [1, 2, 3, 4, 5, 6, 7] # traditional for loop l = [] for n in nums: l.append(n) print(l) # prints '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' # meet list comprehension l = [n for n in nums] print(l) # prints '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' # get square of each number l = [n*n for n in nums] print(l) # prints '[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]' # same thing achieved using 'map' + 'lambda' # 'map' means running everything in the list for a certain function # 'lambda' means an anonymous function l = map(lambda n: n*n, nums) for x in l: print(x) # prints # 1 # 4 # 9 # 16 # 25 # 36 # 49 # 64 # 81 # 100 # using 'if' in list comprehension l = [n for n in nums if n%2 == 0] print(l) # prints '[2, 4, 6, 8, 10]' # returning tuples with two for loops in list comprehension l = [] for letter in "ab": for num in range(2): l.append((letter, num)) print(l) # prints '[('a', 0), ('a', 1), ('b', 0), ('b', 1)]' # same thing using list comp l = [(letter, num) for letter in "ab" for num in range(2)] print(l) # prints '[('a', 0), ('a', 1), ('b', 0), ('b', 1)]' |
Dict Comprehensionscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | names = ["Robert Downey Jr", "Chris Evans", "Chris Hemsworth", "Mark Ruffalo"] heros = ["Ironman", "Captain America", "Thor", "Hulk"] # traditional dictionary using zip() d = {} for name, hero in zip(names, heros): d[name] = hero for name in d: print(name + " - " + d[name]) ''' prints Mark Ruffalo - Hulk Chris Hemsworth - Thor Robert Downey Jr - Ironman Chris Evans - Captain America ''' # meet dict comprehension d = {name: hero for name, hero in zip(names, heros)} for name in d: print(name + " - " + d[name]) ''' prints Mark Ruffalo - Hulk Chris Hemsworth - Thor Robert Downey Jr - Ironman Chris Evans - Captain America ''' # dict comprehension with condition d = {name: hero for name, hero in zip(names, heros) if name != "Mark Ruffalo"} for name in d: print(name + " - " + d[name]) ''' prints Chris Hemsworth - Thor Robert Downey Jr - Ironman Chris Evans - Captain America ''' |
Set Comprehensionscode
1 2 3 4 5 6 7 8 9 10 11 | nums = [1, 1, 2, 1, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9] # traditional set (list of unique elements) s = set() for n in nums: s.add(n) print(s) # prints {1, 2, 3, 4, 5, 6, 7, 8, 9} # meet set comprehension s = {n for n in nums} print(s) # prints {1, 2, 3, 4, 5, 6, 7, 8, 9} |
Generator Expressionscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # I need to yield 'n*n' for each 'n' in nums nums = [1,2,3,4,5,6,7,8,9] # traditional generator function def gen_func(nums): for n in nums: yield n*n m = gen_func(nums) for i in m: print(i) # generator expression m = (n*n for n in nums) for i in m: print(i) ''' both prints 1 4 9 16 25 36 49 64 81 ''' |
Lambdacode
1 2 3 4 5 6 7 8 9 10 11 | # a lambda function = a small anonymous function # takes any number of arguments, but can have only one expression # lambda arguments : expression # lambda function with one argument add_hundred = lambda x : x + 100 print(add_hundred(5)) # prints 105 # lambda function with multiple arguments multiply = lambda a, b, c : a*b*c print(multiply(10,5,10)) # prints 500 |
Generatorscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # generators uses the keyword 'yield' to take one element at a time # it helps increase performance and make code more readable def square_numbers(nums): for i in nums: yield (i*i) nums = square_numbers([1,2,3,4,5]) print(type(nums)) # <class 'generator'> print(nums) # <generator object square_numbers at 0x0000018525078B48> for n in nums: print(n) # prints # 1 # 4 # 9 # 16 # 25 # another example def people_list(num_people): result = [] for i in xrange(num_people): person = { "id" : i, "name" : random.choice(names), "major" : random.choice(majors) } result.append(person) return result def people_generator(num_people): for i in xrange(num_people): person = { "id" : i, "name" : random.choice(names), "major" : random.choice(majors) } yield person t1 = time.clock() people = people_list(1000000) t2 = time.clock() print("[INFO] Took {} seconds".format(t2-t1)) # prints # [INFO] Took 1.2467856325541558 seconds t1 = time.clock() people = people_generator(1000000) t2 = time.clock() print("[INFO] Took {} seconds".format(t2-t1)) # prints # [INFO] Took 0.12330942238179077 seconds |
args & kwargscode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # *args used to pass non-keyworded variable-length arguments to a function def my_nums(*args): for n in args: print(n, end=" ") print(type(args)) # prints my_nums(1,2,4,5,6) # prints # '1 2 4 5 6' # <class 'tuple'> # **kwargs used to pass keyworded variable-length arguments to a function def my_fullname(**kwargs): for key, value in kwargs.items(): print(key + " - " + value) print(type(kwargs)) # prints my_fullname(firstname="Gogul", lastname="Ilango") # prints # lastname - Ilango # firstname - Gogul # <class 'dict'> |
Modules
Identifiers
| \d | any number |
| \D | anything but a number |
| \s | space |
| \S | anything but a space |
| \w | any character |
| \W | anything but a character |
| . | any character, except for a newline |
| \b | the whitespace around words |
| \. | a period |
Modifiers
| {1,3} | expecting 1-3 digits ~ \d{1,3} |
| + | match 1 or more |
| ? | match 0 or 1 |
| * | match 0 or more |
| $ | match the end of a string |
| ^ | match the start of a string |
| | | either or (\d{1-3} | \w{5-6}) |
| [] | range or variance |
| {x} | expecting "x" amount (of digits) |
White Space Characters
| \n | new line |
| \s | space |
| \t | tab |
| \e | escape |
| \f | form feed |
| \r | return |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import re # multi-line string example str = ''' Rahul is 19 years old, and Ashok is 24 years old. Murali is 65, and his grandfather, Karthik, is 77. ''' # findall() ages = re.findall(r'\d{1,3}', str) names = re.findall(r'[A-Z][a-z]*', str) print(ages) # prints ['19', '24', '65', '77'] print(names) # prints ['Rahul', 'Ashok', 'Murali', 'Karthik'] # finditer() ages = re.finditer(r'\d{1,3}', str) for m in ages: print(m.group()) # prints # 19 # 24 # 65 # 77 # split() str = "This is an example string" splitted = re.split(r'\s*', str) print(splitted) # prints ['This', 'is', 'an', 'example', 'string'] # match() str = "Dogs are braver than Cats" matches = re.match(r'[A-Z][a-z]*', str) print(matches.group()) # prints "Dogs" # search() str = "For data science help, reach<EMAIL_ADDRESS>searches = re.search(r'([\w]+)@([\w\.]+)', str) print(searches.group()) # prints<EMAIL_ADDRESS>print(searches.group(1)) # prints support print(searches.group(2)) # prints datacamp.com # sub() str = "Ironman is the strongest avenger!" result = re.sub('Ironman', 'Thor', str) print(result) |
os modulecode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # os module is a powerful module in python import os # get current working directory print(os.getcwd()) # prints 'G:\\workspace\\Python' # change current working directory os.chdir("G:\\workspace\\python\\learning") print(os.getcwd()) # prints 'G:\\workspace\\python\\learning' # list directories in the current working directory print(os.listdir()) # prints ['built-ins', 'Lists', 'numpy', 'strings'] # list only files in the current working directory files = [f for f in os.listdir('.') if os.path.isfile(f)] for f in files: print(f) # create a directory in the current working directory os.mkdir("dicts") os.makedirs("dicts/nested-dicts") # remove a directory in the current working directory os.rmdir("dicts") os.removedirs("dicts/nested-dicts") # rename a file or directory os.rename("Lists", "lists") # stats of a file or directory os.stat("lists") # prints 'os.stat_result(st_mode=16895, st_ino=281474977861215, st_dev=4143122855, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1480252546, st_mtime=1480252546, st_ctime=1480252090)' # traverse a directory tree for dirpath, dirnames, filenames in os.walk("G:\\workspace\\python\\learning"): print("Current Path: ", dirpath) print("Directories: ", dirnames) print("Files: ", filenames) print() ''' prints Current Path: G:\workspace\python\learning Directories: ['Built-ins', 'lists', 'NumPy', 'Strings'] Files: [] Current Path: G:\workspace\python\learning\Built-ins Directories: [] Files: ['evalu.py', 'input.py', 'zipped.py'] Current Path: G:\workspace\python\learning\lists Directories: [] Files: ['list_01.py', 'tuple_01.py'] Current Path: G:\workspace\python\learning\NumPy Directories: [] Files: ['ceilr.py', 'concatenate.py', 'eye_identity.py', 'flatten.py', 'math.py', 'mean_var_std.py', 'min_max.py', 'rev_array.py', 'sum_prod.py', 'zeros_ones.py'] Current Path: G:\workspace\python\learning\Strings Directories: [] Files: ['formatting.py'] ''' # check if a file exist print(os.path.isfile("G:\\workspace\\python\\learning\\Strings\\formatting.py")) # prints 'True' # check if a directory exist print(os.path.exists("G:\\workspace\\python\\learning\\Strings")) print(os.path.isdir("G:\\workspace\\python\\learning\\Strings")) # both prints 'True' # accessing environment variable print(os.environ.get("HOME")) # prints 'C:\\Users\\Gogul Ilango' |
sys modulecode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # sys module is used to parse input arguments given to a python file. # this is used if you call a python script with arguments in command line. import sys firstarg = "" secondarg = "" try: firstarg = sys.argv[1] secondarg = sys.argv[2] except: if (firstarg == ""): print("No first argument!") if (secondarg == ""): print("No second argument!") # error text sys.stderr.write("This is stderr text\n") sys.stderr.flush() sys.stdout.write("This is stdout text\n") |
shutil modulecode
1 2 3 4 5 6 7 8 9 10 11 | # shutil module is used for copying, moving, removing directory trees. import shutil # copy file from one location to another shutil.copyfile("/path/to/file_source", "path/to/file_destination") # recursively copy entire directory tree from source to destination shutil.copytree("source_dir", "destination_dir") # recursively delete a directory tree shutil.rmtree("/one/two/three") |
OOP
Classescode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # create a class class Customer(object): # init method is a must def __init__(self, name, age): self.name = name self.age = age # a simple print method def print_customer(self): print("Customer: {}, Age: {}".format(self.name, self.age)) # define an instance a = Customer("Gogul", "24") a.print_customer() # prints "Customer: Gogul, Age: 24" |
Class Variablescode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | class Customer(object): # this is a class variable raise_amount = 1.05 num_of_custs = 0 def __init__(self, name, age, pay): self.name = name self.age = age self.pay = pay Customer.num_of_custs += 1 def apply_raise(self): print("Customer {} new pay is {}".format(self.name, float(self.pay) * self.raise_amount)) if __name__ == '__main__': # class variable not updated a = Customer("Gogul", "24", "5000") a.apply_raise() # prints Customer Gogul new pay is 5250.0 # class variable updated b = Customer("Mahadevan", "25", "6000") b.raise_amount = 2.05 b.apply_raise() # Customer Mahadevan new pay is 12299.999999999998 # print dict of an instance print(a.__dict__) # prints {'name': 'Gogul', 'age': '24', 'pay': '5000'} # There are 2 customers print("There are {} customers".format(Customer.num_of_custs)) |
How to's
How to handle files?code
1 2 3 4 5 6 7 8 9 10 | '''
four different methods (modes) to open a file
"r" - read; default mode; opens a file for reading, error if the file does not exist.
"a" - append; opens a file for appending, creates the file if it does not exist.
"w" - write; opens a file for writing, creates the file if it does not exist.
"x" - create; creates the file, returns an error if the file exist.
"t" - text; default/text mode
"b" - binary; binary mode
'''
|
How to read file line-by-line?code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # not the memory efficient way filename = "entry_1.txt" with open(filename) as f: data = f.readlines() # remove whitespaces at end of each line data = [x.strip() for x in data] # memory efficient way filename = "entry_1.txt" data = [] with open(filename) as f: for line in f: data.append(line) # remove whitespaces at end of each line data = [x.strip() for x in data] |
How to write file line-by-line?code
1 2 3 4 5 | l = ["pikachu", "charmander", "pidgeotto"] fout = open("entry2.txt", "w") for x in l: fout.write(x) fout.close() |
How to load json file?code
1 2 3 4 5 | import json file_input = "data.json" with open(file_input) as data_file: data = json.load(datafile) |
How to check if list is empty?code
1 2 3 4 5 6 7 | # method 1 if not myList: print("list is empty") # method 2 if len(myList) == 0: print("list is empty") |
How to access index in for loop?code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | myList = ["a", "b", "c"] # method 1 for idx, l in enumerate(myList): print(str(idx) + "-" + l) # method 2 idx = 0 for l in myList: print(str(idx) + "-" + l) idx += 1 # both methods print # 0-a # 1-b # 2-c |
How to sort a dictionary by key or value alphabetically?code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | a = {} a["India"] = "Dhoni" a["SouthAfrica"] = "ABD" a["Australia"] = "Smith" # sort dictionary based on 'key' alphabetically for key in sorted(a.keys(), key=lambda x:x.lower()): print("{0} - {1}".format(key, a[key])) # prints # Australia - Smith # India - Dhoni # SouthAfrica - ABD # sort dictionary based on 'value' alphabetically for key in sorted(a.keys(), key=lambda x:a[x]): print("{0} - {1}".format(key, a[key])) # prints # SouthAfrica - ABD # India - Dhoni # Australia - Smith |
How to call tcl procedure in python?code
1 2 3 4 5 6 | # let's say you have a tcl file named 'test.tcl' with contents as below. puts "Hello" proc sum {a b} { set c [expr $a + $b] puts "Addition of $a and $b is $c" } |
1 2 3 4 5 6 7 8 9 | # to call a tcl proc in python, we need 'tkinter' library which comes with python usually. import tkinter r = tkinter.Tk() r.tk.eval("source test.tcl") r.tk.eval("sum 10 20") # prints # Hello # Addition of 10 and 20 is 30 |
Resources
In case if you found something useful to add to this article or you found a bug in the code or would like to improve some points mentioned, feel free to write it down in the comments. Hope you found something useful here.
Happy learning!


Frustrated with trying to learn about Minitest and the related ecosystem?
Whether you're already an experienced tester or struggling to get started, The Minitest Cookbook has something for you.
Sign up here, and I'll send you three chapters free along with regular Ruby and Rails development articles.


Hello I'm Atte Vuorinen Programmer and Game Developer from Finland. What I mostly do Software Development Game Development Engineering
Skills Programming Languages C# C/C++ CMake Haxe Java Script Python Techniques Naming Conventions Version Control Software Unity3D Git Matlab / Scilab Blender Inkscape Others


Hello, I am Jessica Wu from Toronto. I am a fast learner and highly adaptable to new concepts or changes. I am also a team player and will embrace the challenges occur during development.


The Zen of Python
A collection of 20 "guiding principles" for writing computer programs and why not in our daily life
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one—and preferably only one—obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea—let's do more of those!


virtual Friday
`Prev `__
V
`Next `__
--------------
**virtual Friday**: n.
(also logical Friday) The last day before an extended weekend, if that
day is not a ‘real’ Friday. For example, the U.S. holiday Thanksgiving
is always on a Thursday. The next day is often also a holiday or taken
as an extra day off, in which case Wednesday of that week is a virtual
Friday (and Thursday is a virtual Saturday, as is Friday). There are
also virtual Mondays that are actually Tuesdays, after the three-day
weekends associated with many national holidays in the U.S.
--------------
+---------------------------------+----------------------------+------------------------------------+
| `Prev `__ | `Up <../V.html>`__ | `Next `__ |
+---------------------------------+----------------------------+------------------------------------+
| virtual beer | `Home <../index.html>`__ | virtual reality |
+---------------------------------+----------------------------+------------------------------------+


Pathfinding algorithms are a class of algorithms that find the shortest path from one node to another on a given graph.
Path is a visualizing tool that shows how different pathfinding algorithms work.
The program's objective is to go from the start node to the end node using a pathfinding algorithm. The program can only move horizontally or vertically, with each movement having a cost of one. Once the program is complete, the shortest path will be illuminated in yellow.
Click the 'Algorithms' tab and select one of the algorithms from the dropdown menu.
If you want to learn more about the algorithms listed, then click the 'Info' button that is located at the bottom of the page.
Click or hold your mouse down over cells to create walls.
Press the Start button in the upper right-hand corner to start your pathfinding algorithm!
Hold the mouse down and drag the start/end node to a new location.
Click the 'Mazes' tab and select one of the algorithms from the dropdown menu and a randomized maze will be created for you.
If you want to revisit this tutorial, click the 'Tutorial' button at the end of the page.
If you want to see other projects that I've created, check out my github!
GithubHow It Works: DFS starts at the root node and explores as far as possible along each branch before backtracking.
Analysis: This is a poor algorithm for pathfinding. It is unweighted and does not guarantee the shortest path.
Complexity: The Time complexity of DFS is also O(V + E) when Adjacency List is used and O(V^2) when Adjacency Matrix is used, where V stands for vertices and E stands for edges.
Fun Fact: This algorithm was first investigated in the 19th century by French Mathematician Charles Trémaux.
How It Works: BFS starts at the root node and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level.
Analysis: This is an OK algorithm for pathfinding. It is unweighted but guarantees the shortest path.
Complexity: The Time complexity of BFS is O(V + E) when Adjacency List is used and O(V^2) when Adjacency Matrix is used, where V stands for vertices and E stands for edges.
Fun Fact: This algorithm was first invented in 1945 by Konrad Zuse and was submitted in his rejected PhD thesis, but was not published until 1972.
How It Works: In Dijkstra's algorithm, all of the nodes in the graph (except the starting node) are initialized with a distance equal to 'infinity.' These distances represents the cost to get from the starting node to the current node, with the starting node having a distance of zero. At the beginning of each iteration, the node with the smallest distance that hasn't been explored yet is visited. These nodes are stored in a min-heap data structure. When a node is visited, all of the neighbors' distances are updated, and if any of the neighbor's distances are lessened, then the algorithm pushes the node onto the min-heap. This continues until the end node has been reached.
Analysis: This is an OK algorithm for pathfinding. This algorithm performs very well in trees with unequal distances between nodes. But since this program only explores horizontally/vertically (with each move costing one), it behaves exactly the same as BFS. It is unweighted but guarantees the shortest path.
Complexity: Time Complexity of Dijkstra's Algorithm is O(V^2) but with min-priority queue it drops down to O(V+ElogV).
Fun Fact: Edsger Dijkstra invented this algorithm in twenty minutes.
How It Works: A* uses the same min-heap data structure that is implimented in Dijkstra's, but it expands upon Dijkstra's criteria for selecting the next node to explore. Dijkstra's chooses the node with the smallest distance from the starting node to be explored next. However, A* ranks nodes differently: it has a heuristic function that evaluates how far a node has traveled from the starting node and how far it is from the end node. This heuristic function makes the algorithm 'smart' since it is able to expand in a direction of interest. My implimentation of A* uses Euclidean distance for the end node distance calculation.
Analysis: This is the one of the best algorithms for pathfinding. It is weighted and it guarantees the shortest path.
Complexity:The time complexity of A* depends on the heuristic. In the worst case of an unbounded search space, the number of nodes expanded is exponential in the depth of the solution (the shortest path) d: O(bd), where b is the branching factor (the average number of successors per state).
Fun Fact: A* was first created for the 'Shakey Project', which had the aim of building a mobile robot that could plan its own actions. It was later published in 1968 by Stanford Research Institute scientists.


{% extends "splunkdj:base_with_app_bar.html" %} {% load splunkmvc %} {% block title %}Form Inputs with Tokens - Web Framework Toolkit{% endblock title %} {% block css %} {% endblock css %} {% block content %}
You can build simple dashboards with form views using JavaScript
and Django template tags. This example shows how to parameterize
a search query using two tokens, $count$
and $host$
,
and the values of these tokens are acquired from two form views:
The $count$
token is bound to the dropdown list (Dropdown view).
The $host
is bound to the radio button group
(RadioButtonGroup view), which is populated with host values from the
results of a metadata search.
The defaults for these tokens are set in JavaScript. Rather than using event handlers to update the searches with new values when the form inputs change, the values are updated using token data-binding mechanisms.
How many events would you like to see?
{% dropdown id="counts" default="10" value="$count$"|token_safe %}Which host should we use?
{% radiogroup id="host-radio" managerid="hostsearch" valueField="host" default="*" value="$host$"|token_safe %}


Police stop vehicle in Sutton Coldfield cul-de-sac after pursuit of 'stolen car'
“Me and my boyfriend are horrified as we normally walk the dog around this time and we could've been caught up in some kind of crossfire," said Streetly resident Lisa Williams
by Nick HornerOfficers hunting a suspected stolen vehicle swooped on a Sutton Coldfield street with the police helicopter hovering overhead.
The dramatic chase took place on a four-mile route from Witton Lodge Road in Erdington to Links View in Streetly, close to Sutton Park, on Sunday (November 17) at around 9pm.
Eyewitnesses reported the police helicopter tracking the car through Erdington, Banners Gate and Streetly. Police are believed to have attempted to stop the vehicle using a ‘stinger’ strip of spikes by the Shell garage.
A witness on the Streetly Neighbourhood Alerts Facebook page said: “There was a police car on the shell exit slip packing away what looked like a stinger strip and further round the island at Thornhill Road there were other police cars and a helicopter above.”
The police stop in Links View was captured on Lisa Williams’ Ring video doorbell camera. Ms Williams said: “The incident came up on out doorbell camera as the motion detection was set off.
The video appears to show police offers shouting and then detaining someone.
“It looked like they had someone on the floor. Apparently there was lots of goings all around.
“Me and my boyfriend are horrified as we normally walk the dog around this time and we could've been caught up in some kind of crossfire or whatever else was going on. Luckily we were out and when we got back there was still an unmarked police car in our close.”
A spokeswoman for West Midlands Police said: “Police spotted a suspected stolen car in Witton Lodge Road in Erdington, at just after 9.05pm on Sunday (November 17). Following a short pursuit the car stopped in Links View, Streetly, and the driver was spoken to.
“Enquiries are ongoing.”
No arrests have been made.


Deploy your mvp in minutes, not days. WT offers you a a wide selection swapable sections for your landing page.
Peanut butter jelly time, yeah.