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 / make_alias.sh
Last active September 29, 2016 11:54
Utility for easily creating aliases from the command line. Can manually specify commands or use -l flag to read last item in bash_history
#!/usr/bin/env bash
# -l flag uses last command from history file instead
if [ $1 == -l ]
then
full=`awk 'END{print}' ~/.bash_history`
echo "Enter the short command to alias"
read short
echo "alias "$short"='$full'" >> ~/.bash_profile
source ~/.bash_profile
@looneym
looneym / main.js
Created November 15, 2016 14:40
Example showing how to use pagination when retrieving a list of conversations from the Intercom API
// Author: Micheal Looney
//
// This script hits the list conversations endpoint of the API and subsequently traverses each pages of results by
// recursivly calling the handleResponse() function when the pagination object contains a next parameter.
//
// For each conversation it simply extracts the conversation_id and pushes it to an array
var Intercom = require('intercom-client');
// set your Personal Access Token here
@looneym
looneym / updated_at.js
Created November 16, 2016 10:53
Script to test default ordering of list conversations endpoint on Intercom
// Author: Micheal Looney
//
// Script to test default ordering of list conversations endpoint on Intercom
var Intercom = require('intercom-client');
// set your Personal Access Token here
var token = "";
var client = new Intercom.Client({ token: token });
@looneym
looneym / main.py
Created November 28, 2016 13:13
Using the request library with the Intercom REST API.
import requests
import urllib
import commentjson
"""
Install dependancies with:
pip install commentjson requests
"""
@looneym
looneym / main.py
Created November 29, 2016 00:05
Shitty script to rename files for plex
from imdb import IMDb
from os import listdir
import os
from os.path import isfile, join
ia = IMDb()
def get_name(f):
result = ia.search_movie(f, results=1)
try:
# client code
require 'intercom'
#replace with your values
intercom = Intercom::Client.new(token: 'my_token')
convos = intercom.conversations.find_all(user_id: 'some_user_id', type: 'user')
convos.each { |x| puts x.id }
# sample output one
===> looneym ~/ruby-api-test ruby test.rb
@looneym
looneym / list_comprehension_example.py
Created December 1, 2016 22:58
Simple example showing list comprehensions in Python
class Car:
cars = []
def __init__(self, num, cheap, red, broken):
self.num = num
self.cheap = cheap
self.red = red
self.broken = broken
@looneym
looneym / main.py
Created December 3, 2016 15:15
How to use a personal access token with the (unofficial) Python SDK
from intercom import Intercom, User
# Standard configuration using an app_id and API Key
Intercom.app_id = "my_app_id"
Intercom.app_api_key = "my-super-secret-api-key"
# Usng a Personal Access Token (jus replace the app_id and leave the key blank)
Intercom.app_id = "my-super-secret-PAT"
# Do whatever
@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
@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,