Skip to content

Instantly share code, notes, and snippets.

View solos's full-sized avatar
🎶
Listening music

solos

🎶
Listening music
View GitHub Profile
@solos
solos / gif.swift
Created October 16, 2019 05:39 — forked from SongJiaqiang/gif.swift
保存gif到相册
import AssetsLibrary
import MobileCoreServices
/// 保存gif图到相册
func saveGif2Album() {
let gifPath = Bundle.main.path(forResource: "name", ofType: "gif")
let gifData = NSData(contentsOfFile: gifPath!) as Data
let library = ALAssetsLibrary()
@solos
solos / ViewController.swift
Created July 10, 2019 10:17 — forked from agiletortoise/ViewController.swift
How to update input accessory view to handle iPhone X with external keyboard
//
// ViewController.swift
// TEST_InputViewX
//
// Created by Greg Pierce on 10/5/17.
// Copyright © 2017 Agile Tortoise. All rights reserved.
//
// Demonstrates how to update an input accessory view
// to work on iPhone X with external keyboard attached
// using safe area insets.
@solos
solos / golang-tls.md
Created June 30, 2019 14:32 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
,_---~~~~~----._
_,,_,*^____ _____``*g*\"*,
/ __/ /' ^. / \ ^@q f
[ @f | @)) | | @)) l 0 _/
\`/ \~____ / __ \_____/ \
| _l__l_ I
} [______] I
] | | | |
] ~ ~ |
| |
@solos
solos / toy-bleve-example.go
Created November 25, 2018 13:19 — forked from indraniel/toy-bleve-example.go
This is a toy search example using bleve. It also highlights how to retrieve the orignal input document(s) from the KV store.
package main
// mentioned in bleve google group
// https://groups.google.com/forum/#!topic/bleve/-5Q6W3oBizY
import (
"encoding/json"
"fmt"
"github.com/blevesearch/bleve"
"github.com/blevesearch/bleve/document"
@solos
solos / csrf.js
Created December 31, 2015 07:02 — forked from kayzhu/csrf.js
Send POST request in Angular.js to a CSRF-protected Django view
<script type="text/javascript" src="/angular/angular.js"></script>
<script type="text/javascript" src="/angular/angular-cookies.min.js"></script>
// app.js
// inject ngCookies to your app named 'myApp'.
angular.module('myApp', ['ngCookies']);
// controller.js
function MyCtrl($scope, $http, $cookies) {
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
@solos
solos / dawg.py
Last active August 29, 2015 14:16 — forked from smhanov/dawg.py
#!/usr/bin/python3
# By Steve Hanov, 2011. Released to the public domain.
# Updated 2014 to use DAWG as a mapping.
import sys
import time
DICTIONARY = "/usr/share/dict/words"
QUERY = sys.argv[1:]
# This class represents a node in the directed acyclic word graph (DAWG). It
from tornado import gen
import tornado.testing
import motor
class MyTestCase(tornado.testing.AsyncTestCase):
def test_thing(self):
client = motor.MotorClient('localhost', 27017, io_loop=self.io_loop)
client.open_sync()