Skip to content

Instantly share code, notes, and snippets.

View yentsun's full-sized avatar

Maksim Korinets yentsun

  • SimpleCrew
  • Vung Tau, Vietnam
  • 09:54 (UTC +07:00)
View GitHub Profile
@mattlockyer
mattlockyer / client.js
Last active February 22, 2023 18:30
s3 upload as stream using req stream (extra info in request header)
const file = this.input.files[0];
//console.log(file);
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', (e) => {
console.log(e.target.response);
});
xhr.open('POST', host + 'fileuploadstream', true);
xhr.setRequestHeader('body', JSON.stringify({ id: 'somebucketfolderid', fn: file.name }));
xhr.send(file);
@paskal
paskal / site.conf
Last active September 24, 2024 13:20 — forked from plentz/nginx.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
# views.py
from myproject.myfunctions import upload_profile_picture
def profile_picture(request):
# setup (checking for post, checking if the
# user is authenticated, etc.)
user = request.user
pic_file = request.FILES['profile_picture']
result_url = upload_profile_picture(pic_file)
@yentsun
yentsun / zend_lucene_pagination.php
Created February 1, 2012 14:09
An example of paginating Zend_Lucene search results
<?php
$index = Zend_Search_Lucene::open(your_index_dir);
$query = 'some search query';
$result = $index->find($query);
$perPage = 20;
$page = 5;
$range = 4;
Zend_Paginator::setDefaultScrollingStyle('Elastic');