Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo "Show running mode (UEFI or BIOS) of your system."
echo "@see https://askubuntu.com/a/947856"
echo ""
mode=$(test -d /sys/firmware/efi && echo UEFI || echo BIOS)
echo "System runnging in mode: $mode"
#!/bin/bash
echo "List USB devices with associated device file (/dev/*)."
echo "@see lsusb"
echo ""
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
<?php
/**
* Add the specified HTTP header to the prepared request
*/
function addHeader(Symfony\Component\BrowserKit\Client $client, string $name, $value)
{
$client->setServerParameter('http-' . $name, $value);
}
@Cosmologist
Cosmologist / Brother-Keenetic-CUPS-Cloud.md
Last active December 14, 2018 17:05
Нюансы организации беспроводного доступа к принтеру Brother DCP-7060D подключенного к роутеру Zyhel Keenetic Giga 2 с прошивкой OpenWrt.

CUPS

  • Делайте cupsd -t если что-то не работает - cupsd проанализирует конфигурационный файл и может выдать ошибки, которые потом тяжело будет отловить
  • При попытке печати тестовой страницы выдавалось No such file or directory и ничего не происходило, подробностей больше не было - помог strace - в поставке cups не было ресурса с баннером (тестовая страница) - на него он и ругался.

Драйвера

Brother распространяет драйвера для Linux в виде .deb, .rpm и .ppd (но не для всех принтеров) - 7060D как раз без .ppd. Ставим драйвера локально - у нас появится файлик DCP7060D.ppd - копируем его на роутер в /opt/etc/init.d/cups/ppd, принтер заведенный в CUPS должен называться также - DCP7060D.

int Distance = 0; // Record the number of steps we've taken
// the setup function runs once when you press reset or power the board
void setup() {
// Enable control signal pin
pinMode(11, OUTPUT);
// Dir pin
pinMode(12, OUTPUT);
import quantize
image.open('test.png')
# Quantize image with 8 colors (3-bit)
image = quantize.quantize(image, quantize.PALETTE_8_COLORS)e
image.save('test_quantize.png')
@Cosmologist
Cosmologist / scale.py
Created January 31, 2014 12:57
Convert image to black and white colors - http://pickbox.ru/edit/309
def blackwhitescale(im):
"""
Convert image to black and white colors
Each pixel to be either fully black (0, 0, 0) or fully white (255, 255, 255)
"""
# Convert to grayscale
gray = im.convert('L')
# Scale to white or black (whichever is closest).
@Cosmologist
Cosmologist / SubscriptionsStatExtension.php
Created January 28, 2014 15:06
Get subscription information for user from forum (CCDNForumForumBundle) subscription - http://pickbox.ru/e/256
<?php
namespace Acme\ForumBundle\Twig;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
use Symfony\Component\Security\Core\SecurityContext as SecurityContext;
class SubscriptionsStatExtension extends \Twig_Extension
{
public function __construct(SecurityContext $securityContext, Container $container)
@Cosmologist
Cosmologist / image_split_vertical.py
Last active January 3, 2016 08:49
Split the image into several vertical images - http://pickbox.ru/e/242
#-*- coding: utf-8 -*-
def split_vertical(im, separator_color=None):
"""
Split the image into several vertical images.
Split points defined by solid vertical strip of a background color
"""
# Original image size
image_width = im.size[0]
<?php
function safe_nl2br($string) {
$string = str_replace("\n", "<br />", $string);
foreach (array('pre', 'code') as $tag) {
if(preg_match_all("/$tag>(.*?)<\/$tag/", $string, $match)) {
foreach($match as $a){
foreach($a as $b){
$string = str_replace("<$tag>".$b."</$tag>", "<$tag>".str_replace("<br />", "", $b)."</$tag>", $string);