Skip to content

Instantly share code, notes, and snippets.

GAN Media Group ganmedia

Block or report user

Report or block ganmedia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View js
// Based on blog post: https://www.sitepoint.com/how-to-build-your-own-ai-assistant-using-api-ai/
// Source code: https://github.com/sitepoint-editors/Api-AI-Personal-Assistant-Demo/blob/master/index.html.
// Demo: https://devdiner.com/demos/barry/
// When ready :)
jQuery(document).ready(function() {
/*
* When the user enters text in the text input text field and then the presses Enter key
*/
View Django and Python 3 in Amazon Lightsail
sudo apt-get update
sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx
sudo -u postgres psql
- paste this code in postgres console:
CREATE DATABASE django_project;
CREATE USER username WITH PASSWORD 'pass1234';
ALTER ROLE username SET client_encoding TO 'utf8';
ALTER ROLE username SET default_transaction_isolation TO 'read committed';
View Arduino and Firebase
#coding=utf-8
from pyfirmata import Arduino, util
from firebase import firebase
import time
board = Arduino('com3')
firebase = firebase.FirebaseApplication('https://<<MY ARDUINO PROJECT>>.firebaseio.com', None)
it = util.Iterator(board)
View gist:72d0faf58f668b0265bd
from bisect import bisect_left
array = [1, 3, 5, 6]
target = 5
def element_position(array, target):
return bisect_left(array, target)
print 'Target is/or would be in ', element_position(array, target)
View gist:ecf0344b10fc2d57daa9
array = [1, 3, 5, 6]
temp = array
target = 5
if target in array:
print 'Target is in ', array.index(target)
else:
temp.append(target)
temp.sort()
You can’t perform that action at this time.