Posts

Google recaptcha validation in yii2 always fails -

i use himiklab/yii2-recaptcha-widget . validation error when submit form. {"captcha":["the verification code incorrect."]}. form: $form->field($model, 'captcha',['template' => "{input}\n{hint}\n{error}"])->widget( \himiklab\yii2\recaptcha\recaptcha::classname(), [ 'sitekey' => <mysitekey>, 'widgetoptions' => ['id'=>'recaptcha1'] ]) controller: if(isset($_post['contact'])){ if ($model->load(yii::$app->request->post()) && $model->save()) { what doing wrong? the problem yii run validation twice, on validation() method , during save executes again validation, cause first validation successful second returns error. so, second case need save without running validations, save(false). the second chance might unhook validation of captcha before safe() method.

php - htaccess redirect to a maintainance file -

i have htaccess in public directory: <ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c> options -multiviews </ifmodule> rewriteengine on rewritebase /sub/web1/ # redirect trailing slashes... rewriterule ^(.*)/$ /$1 [l,r=301] # here need som magical oneliner redirect stuff maintenance.html # no idea how write ;( # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule> and want add rule inside, when uncomment rule, links hit http://example.com/sub/web1/ or files down line, redirected http://example.com/sub/web1/maintenance.html i have tried add: directoryindex maintenance.html redirects http://example.com/sub/web1/ , if have subfolder or specific files http://example.com/sub/web1/posts , useless. is there oneliner can pull domain name hasn't have typed absolutely? so, example.com - or whatever domain...

jquery - JavaScript getSelection issue -

if (!window.x) { x = {}; } x.selector = {}; x.selector.getselected = function() { if (window.getselection) { t = window.getselection(); } else if (document.getselection) { t = document.getselection(); } else if (document.selection) { t = document.selection.createrange().text; } return t; } function htmlspanhlt() { element = document.createelement("span"); element.setattribute('class', 'hlt'); return element; } function highlight_text(sel) { span = htmlspanhlt(); if (sel.getrangeat) { range = sel.getrangeat(0); } span.appendchild(range.extractcontents()); range.insertnode(span); } <div class="highlight"> <p> lorem ipsum dolor sit amet, eu ius autem labitur complectitur, eos aliquip nostrud ei, ludus erroribus vel ex. sea ex erat quaeque intellegam, et diam iusto deterruisset sea. summo minimum periculis pro ea, diam soleat id pro. cu putent inim...

django - LookupError: App 'users' doesn't have a 'user' model -

django 1.9.7 i'm using pyenv virtualenv autoenv i want extend user model so, decide use abstractuser (abstractuser's class meta abstract = true, can't make table, inheritance class can make table, right??) anyways (wef project name) make app wef/users/models/__init__.py from .user import user in wef/users/models/user.py from django.contrib.auth.models import abstractuser django.db import models class user(abstractuser): phonenumber = models.charfield( max_length = 11, blank = true, null = true ) and add users app in settings.py installed_apps = [ [...] 'users', ] auth_user_model = 'users.user' so, think when makemigrations, migrate django make model table user... python wef/manage.py makemigrations users it shows error traceback (most recent call last): file "/users/hanminsoo/.pyenv/versions/study_alone/lib/python3.5/site-packages/django/apps/config.py...

python - Error while installing GDAL -

i'm trying install gdal through pip. i'm getting error: extensions/gdal_wrap.cpp:3089:27: fatal error: cpl_vsi_error.h: no such file or directory #include "cpl_vsi_error.h" ^ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed exit status 1 i used these commands: sudo apt-get install libgdal-dev export cplus_include_path=/usr/include/gdal export c_include_path=/usr/include/gdal pip install gdal can tell me how install ? check installed gdal using command gdal-config --version then run commands: pip install --download="some_path" gdal cd some_path tar -xvzf gdal-<version>.tar.gz cd gdal-<version> python setup.py build_ext --include-dirs=/usr/include/gdal/ python setup.py install

alias - Tableau: How to edit aliases, if I use only one source? -

Image
i know can change aliases if have primary , secondary source in use. however, while using 1 source (excel), there's no option 'edit alias'. there alternative, i.e. create calculate field? specifically: need keep months in order, don't want display digits instead of months names. want change {2;3;...;11} {"october";...;"june"} on axis. i assume have data similar - @ least regards month_number , month_name . there few ways want... option #1 - sort field: right-click on month name field , select sort. within popup, under sort by , check "field" , select field contains number of months. aggregation can minimum or maximum - benign long showing data @ month grain (which are). option #2 - use , hide number field header: make sure month number field discrete dimension place before month name field on shelf (rows or columns). right click on month number field , un-check 'show header'. option #3 - cr...

java - How to organise the tests of an expensive object -

i have class want test junit. creating of object of type involves lot of io, takes 5 seconds. a mutable , want test different methods change a. in kind of dilemma: if create virgin object every test method, takes long. creating 1 huge test method lot of asserts seems bad idea isolate causes of possible errors. "repairing" object of type after each test methods seems dangerous because if repairing not done correctly, other test methods might fail without proper reason. i create deep copy of instance of every test method, means have change class test it. what suggest?