Skip to content

Instantly share code, notes, and snippets.

@tomat
tomat / part1.py
Created October 30, 2018 12:47
TF part 1
import tensorflow as tf
import numpy as np
# List out our bandits. Currently bandit 4 (index#3) is set to most often provide a positive reward.
# Reward of 1 if given if the random number 0-1 is lower than the bandit value
bandits = [0.5, 0.1, 0.3, 0.8]
num_bandits = len(bandits)
def pullBandit(bandit):
// Call
loadAdformAd(container, adformId, name, extraParams, () => {
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.onViewable();
}, 1000);
});
this.timer = setTimeout(() => { this.onViewable(); }, 8000);
// Function
# app/config/config.yml
services:
monolog.formatter.request:
class: Monolog\Formatter\LineFormatter
arguments:
- "[%%datetime%%] [%%extra.username%%] %%channel%%.%%level_name%%: %%message%% %%context%% [%%extra.postParams%%]\n"
# app/config/config_prod.yml
monolog:
handlers:
<?php
namespace AppBundle\Monolog;
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
<?php
namespace AppBundle\Cache;
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpFoundation\RequestStack;
use Doctrine\Common\Cache\CacheProvider;
use AppBundle\Model\SomethingGeneratorInterface;
/**
import React, { Component } from 'react';
export default class MyTextEditor extends Component {
componentDidMount() {
import('jquery').then((jquery) => {
window.jQuery = jquery;
window.$ = jquery;
import('../lib/redactor/redactor.js').then(() => {
$(this.refs.textarea).redactor();
});
import React, { Component } from 'react';
export default class MyTextEditor extends Component {
constructor() {
super();
this.state = {
redactorLoaded: false,
};
}
(function() {
var errorBoxElement = false;
var showError = function(error) {
if (!errorBoxElement) {
errorBoxElement = document.createElement('div');
errorBoxElement.style.position = 'absolute';
errorBoxElement.style.top = '0';
errorBoxElement.style.bottom = '0';
errorBoxElement.style.left = '0';
errorBoxElement.style.right = '0';
cd {{project}}
# Remove dots from branch name (one may want to do more cleaning here)
branch=$(echo "{{branch}}"|sed "s/\.//g")
if [ "$branch" != "master" ]; then
# Replace the current symlink with the one we saved before
mv -T current_archived current
# Make sure the branches directory exists
cd {{project}}
# Remove dots from branch name (one may want to do more cleaning here)
branch=$(echo "{{branch}}"|sed "s/\.//g")
if [ "$branch" != "master" ]; then
# Cleanup symlinks that may be left over from previous deploy
rm -f current_archived
# Save the current symlink so we can restore it later