Skip to content

Instantly share code, notes, and snippets.

View hakobyansen's full-sized avatar
👑

Senik Hakobyan hakobyansen

👑
View GitHub Profile
@hakobyansen
hakobyansen / cam.js
Last active July 25, 2020 10:55
A simple script to stream a video in the browser.
window.onload = function() {
navigator.getUserMedia({
video: true,
audio: false
}, function(localMediaStream) {
console.log(localMediaStream)
var video = document.querySelector('.camera');
video.srcObject = localMediaStream;
video.onloadedmetadata = function(e) {
@hakobyansen
hakobyansen / run-zap.sh
Last active November 30, 2021 06:39
The usage - "bash run-zap.sh https://example.com h4x0r X-Corp TopSecret". Update the curl call on line 39 - replace placeholders with real channel ID and bot auth token. If you don't need slack notification - simply comment out that line.
#!/bin/bash
# Assigning parameters to variables for better readability
host="$1"
by="$2"
for="$3"
project="$4"
# Getting current timestamp to use it in the session name
timestamp=$(date '+%s');
<?php
$converter = new Converter('ZZ');
echo $converter->getResult() . PHP_EOL;
class Converter
{
private $letters;
private $result = 0;
@hakobyansen
hakobyansen / input_type_number.html
Last active May 20, 2019 16:21
An example of how to validate maxlength attribute for input type="number" and how to do not allow to put "e" symbol.
<input type="number"
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
maxlength="6" required/>
<script>
// do not allow to put "e" symbol
$('input[type="number"]').on('keydown', function(e) {
let keyCode = e.keyCode || e.which;
if( keyCode == 69 )
@hakobyansen
hakobyansen / python3.6
Created May 16, 2019 18:00
Install python 3.6 from sources
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6.3
./configure --enable-optimizations
make -j8
sudo make altinstall
python3.6
@hakobyansen
hakobyansen / Handler.php
Last active April 25, 2019 15:18
Even if you have file size validation implemented, you will get PostTooLargeException if you're trying to upload file larger than size specified in your php.ini config file. This gist shows how you can handle PostTooLargeException in Laravel.
<?php
// App\Exceptions\Handler::render()
public function render($request, Exception $exception)
{
if ($exception instanceof PostTooLargeException)
{
// todo: return response or do whatever you need to do
return response()->json(['message' => 'File is too large.'], 422);
}