Skip to content

Instantly share code, notes, and snippets.

@yurtaev
yurtaev / Dockerfile
Created July 28, 2019 18:03
nginx + geoip2 modile
#
# https://github.com/leev/ngx_http_geoip2_module
#
FROM nginx:alpine AS builder
# nginx:alpine contains NGINX_VERSION environment variable, like so:
# ENV NGINX_VERSION 1.15.0
ENV NXG_GEIOP2_VERSION 3.2
@yurtaev
yurtaev / keybase.md
Created April 15, 2015 14:48
keybase.md

Keybase proof

I hereby claim:

  • I am yurtaev on github.
  • I am yurtaev (https://keybase.io/yurtaev) on keybase.
  • I have a public key whose fingerprint is 6363 519A 8CAB 3B90 F44A 0837 2CC3 AFCA E445 A691

To claim this, I am signing this object:

OS|Mac OS X|10.10.0 14A389
CPU|amd64|family 6 model 42 stepping 7|8
Crash|EXC_BREAKPOINT / 0x00000002|0x10b256445|0
Module|Chromium||Chromium|A6A82D6AC0213C3D8747C8B296E96FD30|0x10abd5000|0x10abd5fff|1
Module|Chromium Framework||Chromium Framework|476350E1D4033CF180A2A7E388A7B6E40|0x10abdb000|0x110265fff|0
Module|CoreMIDI||CoreMIDI|B9A13CFD30563E06A2D816518D1457440|0x1107e4000|0x11081bfff|0
Module|libCyrillicConverter.dylib||libCyrillicConverter.dylib|251C52BB5EE6372289DAF3DC802221420|0x110870000|0x110871fff|0
Module|FileProvider||FileProvider|E5C8FF015BC4398686F9892FB81EF0780|0x113f57000|0x113f5afff|0
Module|libFontRegistryUI.dylib||libFontRegistryUI.dylib|9C55337C4D6534C89BB990399B420A6F0|0x1250cd000|0x1250d1fff|0
Module|cl_kernels||<Unknown>|000000000000000000000000000000000|0x1265ca000|0x1265cafff|0
"""
requirements:
- requests http://docs.python-requests.org/en/latest/
- requests-toolbelt https://toolbelt.readthedocs.org/en/latest/
pip install requests requests-toolbelt
"""
import requests
import httplib
import mimetypes
import base64
def post_multipart(host, selector, fields, files, headers):
"""
Post fields and files to an http host as multipart/form-data.
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return the server's response page.
# file: .ebextensions/02-commands.config
container_commands:
00001-docker-privileged:
command: 'sed -i "s/docker run -d/docker run --privileged -d/" /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh'
public func getSSID() -> String? {
let interfaces:CFArray! = CNCopySupportedInterfaces()?.takeUnretainedValue()
if interfaces == nil { return nil }
let if0:UnsafePointer<Void>? = CFArrayGetValueAtIndex(interfaces, 0)
if if0 == nil { return nil }
let interfaceName:CFStringRef = unsafeBitCast(if0!, CFStringRef.self)
let dicRef:NSDictionary! = CNCopyCurrentNetworkInfo(interfaceName)?.takeUnretainedValue().__conversion()
if dicRef == nil { return nil }
let ssidObj:AnyObject? = dicRef[kCNNetworkInfoKeySSID]
if ssidObj == nil { return nil }
@yurtaev
yurtaev / localStorage.coffee
Created August 8, 2014 07:51
Simple localStorage function with Storage API fallback for chrome apps.
# Simple localStorage function with Storage API fallback for chrome apps.
class BaseStorage
getItem: (key) ->
return sessionStorage.getItem(key)
setItem: (key, value) ->
data = {}
data[key] = value
chrome.storage.local.set data, ->
@yurtaev
yurtaev / gist:323d77ee3cf30e293444
Created August 6, 2014 06:35
memcached vs go-memcached
(mc) ✘  ~/Tmp  time python mc.py -a 192.168.1.31:11212 -n 10000
Benchmarking pylibmc...
test_set: 9.433222 seconds
test_set_get: 18.527617 seconds
test_random_get: 35.192981 seconds
test_set_same: 10.686864 seconds
test_set_big_object (100 objects): 0.210625 seconds
test_set_get_big_object (100 objects): 0.411831 seconds
test_set_big_string (100 objects): 0.191070 seconds
test_set_get_big_string (100 objects): 0.373243 seconds
@yurtaev
yurtaev / 0_reuse_code.js
Created June 23, 2014 11:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console