Skip to content

Instantly share code, notes, and snippets.

@agustinhaller
agustinhaller / UploadImageURL.php
Created February 26, 2014 18:10
Given any image url, it uploads to amazon s3
<?php
// Given any image url, it uploads to amazon s3
function UploadImageURL()
{
// $image_url = (isset($_REQUEST["image_url"]) && $_REQUEST["image_url"]!=null) ? $_REQUEST["image_url"] : null;
$image_url = "https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-prn1/t1/p526x296/1965014_10153859707455111_1422873058_n.jpg";
// $image_url = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIWFRQBAwQEBgUGCgYGChAODA0QFA8OEAwNDQ8QDw0ODhANEA8MDA8PDxAQFA4VDw8PDhANDQ4ODRAQDw8UDhAMDA0MDP/AABEIACwALAMBEQACEQEDEQH/xAAaAAADAAMBAAAAAAAAAAAAAAAHCAkDBQYE/8QANBAAAQMDAwMCAwUJAQAAAAAAAQIDBAUGEQAHIQgSMRNBFCJxFzJCYYEVFiM0Q1FTcpEJ/8QAGgEAAgMBAQAAAAAAAAAAAAAAAwQABQYCAf/EACsRAAEDAwIEBQUBAAAAAAAAAAEAAgMREjEEIRNBUfBxgZGhwQUUImHRsf/aAAwDAQACEQMRAD8AfZtXA0wuFnR51FKrX3jd1N29s2uXRWFqbpVFgvVCUpsZV6baCtQSPdRAwB7kjUUUO7yvW/uszeebcc1Dji1r7I8NtwmPTI/4Gkk8ADyTgFSsnydIT6hkQq4+ATmn0z5zaweJ5BF66+gLcyltQbkiINXSyhC3YkBKlyEYGThJyFeM8YGST76Wh1okdu0jompdAWD8XA9e
@agustinhaller
agustinhaller / add_tests.php
Last active January 4, 2016 04:28
Add Python Tests to truly.am testing framework
<?php
$test_results = array(array('sample' => 'agus', 'subject' => 'dayu', 'confidence' => '5.32442375'),
array('sample' => 'chapman', 'subject' => 'dayu', 'confidence' => '431.866991'),
array('sample' => 'dayu', 'subject' => 'dayu', 'confidence' => '283.407861'),
array('sample' => 'alex', 'subject' => 'dayu', 'confidence' => '455.675758'),
array('sample' => 'ali', 'subject' => 'dayu', 'confidence' => '150.218559'),
array('sample' => 'shayan', 'subject' => 'dayu', 'confidence' => '395.017484'),
array('sample' => 's1', 'subject' => 'dayu', 'confidence' => '92.1327915'),
array('sample' => 's2', 'subject' => 'dayu', 'confidence' => '119.563628'),
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
<?php
function Test()
{
$template_engine = TemplateEngine::get();
$subjects = App::getSubjects();
$test_results = array();
foreach($subjects as $subject)
@agustinhaller
agustinhaller / setinterval-alternative.js
Created November 15, 2013 21:09
Setinterval alternative
// Reference: http://www.thecodeship.com/web-development/alternative-to-javascript-evil-setinterval/
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
@agustinhaller
agustinhaller / TC Hackathon LOG
Last active December 26, 2015 14:49
TC Hackathon LOG
- Create bitbucket repo
- Researching what to do with the face detection and face recognition stuff, investigating opencv or any API.
- Share repo to team mates
- Create local environment
- Initial push
- Clone git repo in team mates computers
- Create heroku app
- Decided we are going to use Sky Biometry API for the face detection and face recognition part
- Decided we are going to use php for the backend and lot of javascript for the frontend
@agustinhaller
agustinhaller / git-rm.sh
Created August 8, 2013 18:31
remove all deleted files - git
git diff --diff-filter=D --name-only -z | xargs -0 git rm
@agustinhaller
agustinhaller / collection_helper.js
Created August 8, 2013 03:20
JS Collection Helper
var collection_helper = (function () {
var collection = [],
$collection = $(collection),
inCollection = function (item) {
//debugger;
var index = -1,
iterator = 0,
total_iterator = $collection.length;
for (iterator; iterator < total_iterator; iterator++) {
@agustinhaller
agustinhaller / makeId.js
Created August 8, 2013 03:06
makeId function
function makeid(length)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for(var i=0; i < length; i++)
{
text += possible.charAt(Math.floor(Math.random() * possible.length));
}