I hereby claim:
- I am inoryy on github.
- I am inoryy (https://keybase.io/inoryy) on keybase.
- I have a public key whose fingerprint is AE1C 94AE 75A4 4DF3 C4EA 99BE 981B B6DB 559A 2267
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Imagine this scenario: A new user on your awesome webpage finds an awesome link, but it's only open to registered users, so he's automatically redirected to login form, then he goes to a register page (or fills embedded form right there) and then gets redirected back to a homepage. Somewhat frustrating experience, don't you think?
Well, let's solve this little problem with some help from [symfony2 authentication listener] (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php). More specifically, by exploiting [already existing feature] (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php#L270) for login form. This feature is actually a simple session parameter that is set the moment
Imagine this scenario: A user on your webpage finds an awesome link, but it's only open to registered users.
Normally our user will be redirected to login page and if they already have an account, they can login and get redirected to the page they were looking for. This is possible thanks to Symfony2 Authentication listener where a session parameter is set to what the last page was before firewall was hit and then purged the moment you login.
But what if they're a new user? After clicking another link to register and filling out the form, how can you redirect them back to the page they're actually looking for?
/** | |
* | |
* @Gedmo\SortableGroup | |
* @ORM\Column(name="fieldName", type="integer") | |
*/ | |
protected $field; | |
/** | |
* @var integer | |
* @Gedmo\SortablePosition |
#!/bin/bash | |
mysqldump <db_name> | gzip > /path/to/backups/<db_name>_`date +'%H-%M_%d-%m-%Y'`.sql.gz | |
echo "<Project name> database backup" | mutt -s "[Backup] `date +'%H:%M %d-%m-%Y'`" <email@email.com> -a /path/to/backups/$(ls /path/to/backups/ -tr | tail -n 1) |
<?php | |
final class FormTypes { | |
const HIDDEN = 'hidden'; | |
const TEXT = 'text'; | |
// ... | |
private __constructor() {} | |
} |
import pandas | |
from sklearn.linear_model import LogisticRegression | |
from sklearn import cross_validation | |
def sanitize(dataset): | |
dataset["Age"] = dataset["Age"].fillna(dataset["Age"].median()) | |
dataset["Fare"] = dataset["Fare"].fillna(dataset["Fare"].median()) | |
dataset.loc[dataset["Sex"] == "male", "Sex"] = 0 | |
dataset.loc[dataset["Sex"] == "female", "Sex"] = 1 |
--- core/modules/book/book.services.yml | |
+++ core/modules/book/book.services.yml | |
@@ -2,3 +2,7 @@ | |
book.manager: | |
class: Drupal\book\BookManager | |
arguments: ['@database'] | |
+ access_check.book.removable: | |
+ class: Drupal\book\Access\BookNodeIsRemovableAccessCheck | |
+ tags: | |
+ - { name: access_check } |
from heapq import heappop, heappush | |
def dijkstra(g, s, f): | |
h = [(0,s)] | |
cost, prev = {}, {} | |
cost[s], prev[s] = 0, None | |
while len(h) > 0: | |
_,v = heappop(h) | |
if v == f: |
from pydoc import locate | |
import tensorflow as tf | |
import numpy as np | |
from seq2seq import tasks, models | |
from seq2seq.training import utils as training_utils | |
from seq2seq.tasks.inference_task import InferenceTask, unbatch_dict | |
class DecodeOnce(InferenceTask): | |
''' |