Skip to content

Instantly share code, notes, and snippets.

server {
server_name www.example.com;
access_log /var/log/nginx/example.com.log;
error_log /var/log/nginx/example.com.error.log debug;
root /home/myuser/example.com/homepage;
sendfile on;
# if the uri is not found, look for index.html, else pass everthing to gunicorn
location / {
index index.html;
@alexcasalboni
alexcasalboni / amazon-rekognition.md
Last active October 11, 2024 16:44
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@alexcasalboni
alexcasalboni / aws-lambda-demo1-restful-api.py
Last active March 6, 2021 13:23
AWS Lambda Coding Session - clda.co/webinar-lambda
def lambda_handler(event, context):
name = event.get('name') or 'World'
print("Name: %s" % name)
return "Hello %s!" % name
@napjon
napjon / from_sklearn.py
Last active September 12, 2017 21:49
Method to convert docs using sklearn to pyLDAVis
def from_sklearn(docs,vect,lda,**kwargs):
"""Create Prepared Data from sklearn's vectorizer and Latent Dirichlet
Application
Parameters
----------
docs : Pandas Series.
Documents to be passed as an input.
vect : Scikit-Learn Vectorizer (CountVectorizer,TfIdfVectorizer).
@clalimarmo
clalimarmo / app_init.js
Created September 15, 2015 18:52
Deep Linking with React + Flux, dispatching an action for app initialization on page load
// example app initialization
$(function() {
Dispatcher.dispatch({
type: 'initialize app',
path: window.location.pathname,
});
});
@clalimarmo
clalimarmo / routes.rb
Created September 15, 2015 16:58
Deep Linking with React + Flux, example Rails routes definition
class ExcludeXhr
def matches?(request)
!request.xhr?
end
end
Rails.application.routes.draw do
constraints(ExcludeXhr.new) do
root 'home#index' # home/index just renders our single page client-side app
get '*path', to: "home#index", via: :all
@clalimarmo
clalimarmo / tasks_app.jsx
Created September 15, 2015 16:52
Deep Linking with React + Flux, main controller view, step 1
TasksApp = React.createClass({
// all component state originates from TaskStore, upstream
getInitialState: function() {
return {
selectedTask: TaskStore.selectedTask(),
tasks: TaskStore.tasks(),
};
},
// and when the TaskStore's state changes, we update this component's
@terhechte
terhechte / pattern-examples.swift
Created August 22, 2015 15:29
Swift pattern examples for the swift, for, and guard keywords
import Foundation
// 1. Wildcard Pattern
func wildcard(a: String?) -> Bool {
guard case _? = a else { return false }
for case _? in [a] {
return true
}
@threepointone
threepointone / sto.js
Created July 28, 2015 07:12
a lightweight flux style store as a component
import React from 'react';
export class Sto extends React.Component{
static defaultProps = {
store: x => x
}
state = {
value: this.props.store()
}
dispatch = action => this.setState({
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.