Skip to content

Instantly share code, notes, and snippets.

@svolobuev
svolobuev / key.go
Created May 25, 2020 20:55
ssh.PublicKey cast to rsa.PublicKey
package rsa
import (
"crypto/rsa"
"golang.org/x/crypto/ssh"
)
func FromSshPublicKey(key ssh.PublicKey) (*rsa.PublicKey, bool) {
if cryptoKey, ok := key.(ssh.CryptoPublicKey); ok {
rsaKey, ok := cryptoKey.CryptoPublicKey().(*rsa.PublicKey)
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/svolobuev/fox/ip
BenchmarkToUint32-4 10000000 118 ns/op 16 B/op 1 allocs/op
BenchmarkToString-4 20000000 56.7 ns/op 16 B/op 1 allocs/op
PASS
ok github.com/svolobuev/fox/ip 2.519s
@svolobuev
svolobuev / osx-10.10-setup.md
Created June 4, 2016 23:42 — forked from kevinelliott/osx-10.10-setup.md
Mac OS X 10.10 Yosemite Setup

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

@svolobuev
svolobuev / AppBundle\Resources\config\services.yml
Created February 26, 2016 06:58
JMS Serializer Subscriber example
services:
serializer.subscriber.news:
class: AppBundle\Serializer\Subscriber\NewsSubscriber
arguments: [@vich_uploader.storage, @liip_imagine.cache.manager, @request_stack]
tags:
- { name: jms_serializer.event_subscriber }
@svolobuev
svolobuev / mysql console.sql
Last active August 20, 2017 15:15
Find nearest geo-object by lat/lon (The Pythagorean theorem or The Haversine Formula)
## формула Пифагора
mysql> SELECT
id, name, address, latitude, longitude, (
3959 * acos (
cos ( radians(59.95238300) )
* cos( radians( latitude ) )
* cos( radians( longitude ) - radians(30.44850400) )
+ sin ( radians(59.95238300) )
* sin( radians( latitude ) )
)
<?php
namespace PrestoHeads\VkBotBundle\Api;
use PrestoHeads\VkBotBundle\VkAuthorize\VkAuthorize;
abstract class ApiResource
{
/**
* @var VkApi