Skip to content

Instantly share code, notes, and snippets.

View ganmedia's full-sized avatar

GAN Media Group ganmedia

View GitHub Profile
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()
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)
#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)
@ganmedia
ganmedia / js
Created January 17, 2018 16:54
// 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
*/
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';