Skip to content

Instantly share code, notes, and snippets.

View solos's full-sized avatar
🎶
Listening music

solos

🎶
Listening music
View GitHub Profile
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):
@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) {
@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"
,_---~~~~~----._
_,,_,*^____ _____``*g*\"*,
/ __/ /' ^. / \ ^@q f
[ @f | @)) | | @)) l 0 _/
\`/ \~____ / __ \_____/ \
| _l__l_ I
} [______] I
] | | | |
] ~ ~ |
| |
@solos
solos / golang-tls.md
Created June 30, 2019 14:32 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
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)
@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 / 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()