Skip to content

Instantly share code, notes, and snippets.

View MikSDigital's full-sized avatar
🎯
Focusing

Mikhail MikSDigital

🎯
Focusing
View GitHub Profile
@MikSDigital
MikSDigital / main.go
Created December 5, 2022 15:00 — forked from mickelsonm/main.go
Golang program to lookup stocks by symbols using Yahoo Finance API.
package main
import (
"encoding/json"
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
@MikSDigital
MikSDigital / ffcapture
Created December 1, 2022 12:58 — forked from seanbutnotheard/ffcapture
FFMPEG Screen capture/stream script
#!/bin/bash
#LICENSE
#To the extent possible under law, the author(s) have dedicated all
#copyright and related and neighboring rights to this software to the
#public domain worldwide. This software is distributed without any warranty.
#See <http://creativecommons.org/publicdomain/zero/1.0/>.
# ffcapture, a hacky script to stream/capture your desktop or a window
# REQUIRES ffmpeg, xwininfo and bc to be installed!
@MikSDigital
MikSDigital / mysql-docker.sh
Created September 3, 2020 13:07 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@MikSDigital
MikSDigital / index.html
Created April 8, 2019 05:44 — forked from jazzido/index.html
Webcam barcode reading (zbar, emscripten)
<!DOCTYPE html>
<html>
<head>
<title>JS in-browser barcode reader</title>
<style type="text/css">
body > div {
position: relative;
width: 320px; height: 240px;
}
video { position: absolute; top: 0; left: 0; width: 320px; height: 240px; }
<?php
define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/xxx/yyy/zzz');
function slack($txt) {
$msg = array('text' => $txt);
$c = curl_init(SLACK_WEBHOOK);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, array('payload' => json_encode($msg)));
curl_exec($c);
@MikSDigital
MikSDigital / PostMessageToSlackChannel.php
Created November 27, 2018 16:32 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar
@MikSDigital
MikSDigital / .htaccess
Created October 28, 2018 16:23 — forked from Guibzs/.htaccess
Symfony 4 .htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /index.php/
@MikSDigital
MikSDigital / MenuBuilder.php
Created September 5, 2018 18:03
Custom KnpMenuBundle navigation bar twig template to support Font Awesome icons & Twitter bootstrap lay-out
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@MikSDigital
MikSDigital / Menu.php
Created August 31, 2018 17:13 — forked from lsv/Menu.php
Symfony 4 - KnpMenuBundle - menu with event
<?php
// src/Menu/Menu.php
namespace App\Menu;
use App\Event\Menu\Topbar\UserMenuEvent;
use Knp\Menu\FactoryInterface;
use Knp\Menu\ItemInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@MikSDigital
MikSDigital / guzzle.php
Created August 25, 2018 09:46 — forked from tomykaira/guzzle.php
Set user-agent in guzzle. client->setDefaultOption('headers/User-Agent', 'foo'); does not work for user-agent.
<?php
require 'vendor/autoload.php';
use Guzzle\Service\Client;
// Create a client with a base URL
$client = new Client('http://requestb.in/1ivmkhd1');
$client->setUserAgent('myuseragent');
// Send a request to https://github.com/notifications
$response = $client->get('')->send();