Skip to content

Instantly share code, notes, and snippets.

View SamMousa's full-sized avatar
🎯
Focusing

Sam SamMousa

🎯
Focusing
  • Sam-IT
  • Netherlands
View GitHub Profile
$('<input name="avg-browser-dev-iq" value="60" type="password" style="display: none;"/>').prependTo('form[autocomplete=off]input[type=password], input[type=password][autocomplete=off]');
setTimeout(function() {
$('input[name=avg-browser-dev-iq]').prop('disabled', true);
}, 15);
<?php
use \yiiunit\data\ar\Customer;
// This enables calling the benchmark from a symlink.
chdir(dirname(($_SERVER['SCRIPT_FILENAME'][0] == '/' ? '': getcwd() . '/') . $_SERVER['SCRIPT_FILENAME']));
include dirname(($_SERVER['SCRIPT_FILENAME'][0] == '/' ? '': getcwd() . '/') . $_SERVER['SCRIPT_FILENAME']) . '/tests/bootstrap.php';
$test = new \yiiunit\framework\db\ActiveRecordTest();
$config = $test->getParam('databases')['mysql'];
unset($config['fixture']);
<?php
namespace prime\commands;
use prime\models\User;
use yii\console\Controller;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
@SamMousa
SamMousa / test
Created January 7, 2016 09:26
Verifying that +sammousa is my blockchain ID. https://onename.com/sammousa
test
@SamMousa
SamMousa / draytest.py
Last active February 21, 2016 22:05 — forked from doobeh/draytest.py
Testing Draytek Vodaphone for Home Automation.
import re
import requests
from collections import namedtuple
import urllib
import base64
# Change these to match your settings. I think the username/password
# is encoded, if it doesn't work, try changing `ENCODE_LOGIN` to False
# and see if it works better
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.js"></script>
<meta charset="UTF-8">
<title>Title</title>
</head>
<template id="mc">
@SamMousa
SamMousa / Secret.php
Last active November 15, 2017 11:21
Secure? secret storage.
<?php
namespace SamIT\Yii2;
class Secret
{
private $secret;
private $key;
<?php
namespace SamIT\Yii2\Behaviors;
use yii\base\Behavior;
use yii\base\InvalidConfigException;
use yii\base\View;
use yii\base\ViewEvent;
class EventHandler.php {
private $handlerClass;
public function __construct(string $handlerClass) {
$this->handlerClass = $handlerClass
}
public function __invoke(... $args) {
$instance = new {$this->handlerClass};
$instance->handle(... $args);
}
@SamMousa
SamMousa / eh.php
Last active January 12, 2018 07:50
<?php
class EventHandler.php {
private $handlerClass;
public function __construct(string $handlerClass) {
$this->handlerClass = $handlerClass
}
public function __invoke(... $args) {
$instance = new {$this->handlerClass};
$instance->handle(... $args);