Skip to content

Instantly share code, notes, and snippets.

View looneym's full-sized avatar
🐧
im in ur ifra breakin ur services

Micheál Looney looneym

🐧
im in ur ifra breakin ur services
View GitHub Profile
@looneym
looneym / generator.py
Created April 4, 2017 21:20
Hackathon Ideas Generator
import random
part1 = ["machine learning solution" , "recursive algorithm" , "e-portal" , "cross platform app" , "revolutionary supply chain management platform", "real-time code sharing tool" , "distributed solutions matrix", "backwards compatible hardware driver", "protocol suite"]
part2 = ["LGBT assylum seekers", "obese children", "the homeless" ,"the elderly", "rural communities" , "young people in disadvantaged areas", ]
part3 = ["bespoke twitter API","Big Data", "the Cloud", "open source software","obfuscated code" , "bitcoin mining", "a deep web neural network", "social media", "distributed networks", "node.js" ,]
rand1 = random.randrange(0,len(part1))
rand2 = random.randrange(0,len(part2))
rand3 = random.randrange(0,len(part3))
@looneym
looneym / create_admin_conversation.py
Created April 3, 2017 12:46
How to create an admin initiated conversation in Intercom using the Python SDK
from intercom.client import Client
intercom = Client(personal_access_token='my_personal_access_token')
intercom.messages.create(**{
"message_type": "inapp",
"body": "What's up :)",
"from": {
"type": "admin",
"id": "1234"
},
@looneym
looneym / Test.java
Last active February 22, 2017 16:30
Base scoped token API operations
import io.intercom.api.Intercom;
import io.intercom.api.User;
public class Test {
public static void main(String[] args){
Intercom.setToken("super_Secret_token");
// Create a user
User user = new User()
@looneym
looneym / main.rb
Created February 20, 2017 16:35
Add and remove companies from an Intercom user
# get a user
user = intercom.users.find(email: "[email protected]")
# add a company to that user
user.companies = [{company_id: 6, name: "Intercom"},]
intercom.users.save(user)
puts user.companies[0].name # "Intercom"
#remove the same company
user.companies = [{company_id: 6, name: "Intercom", remove: true},]
@looneym
looneym / main.js
Created February 15, 2017 11:52
Liquid example
<script>
window.intercomSettings = {
app_id: "hy4aeebl",
name: "{{current_user.name}}", // Full name
email: "{{current_user.email}}", // Email address
created_at: {{current_user.created_at | date: "%s" }}
};
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/hy4aeebl';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
from slackclient import SlackClient
from flask import Flask, request
# Slack config
BOT_TOKEN = os.environ['BOTKEY']
CHANNEL_NAME = "intercom-event-notifications"
app = Flask(__name__)
@app.route('/', methods=['POST'])
@looneym
looneym / main.js
Created February 6, 2017 10:25
Conditionally show the messenger based on page URL
URL = window.location.href;
if (URL.includes("terms")){
termsPage = true;
} else {
termsPage = false;
}
var intercomSettings = {
@looneym
looneym / main.js
Created February 3, 2017 11:31
Conditionally add the messenger at certain times.
var currentdate = new Date();
var currentHour = currentDate.getHours();
if (if currentHour > 9 && currentHour < 5)){
window.intercomSettings = {
app_id: APP_ID,
};
}
@looneym
looneym / main.js
Last active January 9, 2017 17:50
Conditionally populate intercomSettings object with user data if user is logged in
if (CurrentUser.loggedIn)){
window.intercomSettings = {
app_id: APP_ID,
name: CurrentUser.Name,
email: CurrentUser.Email,
user_id: CurrentUser.userID,
};
} else {
window.intercomSettings = {
app_id: APP_ID,
@looneym
looneym / main.py
Created December 5, 2016 15:05
Get the body of a POST request using Flask
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def get_body():
req = request.get_data()
print req
return req