Skip to content

Instantly share code, notes, and snippets.

View jkotchoff's full-sized avatar
💭
1's and 0's

Jason Kotchoff jkotchoff

💭
1's and 0's
View GitHub Profile
@jkotchoff
jkotchoff / 1-oauth2_tweet_from_ruby.md
Last active July 3, 2023 10:54
Twitter v2 Oauth2 send tweet from Ruby on Rails
@jkotchoff
jkotchoff / bitrise.yml
Created April 12, 2020 04:45
Bitrise CI slack workflow
...
workflows:
primary:
steps:
- activate-ssh-key@4.0.3:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- git-clone@4.0.17: {}
- script@1.1.5:
inputs:
- content: |-
@jkotchoff
jkotchoff / appc.js
Last active November 12, 2017 01:29
This Titanium code can be used in an appcelerator project (with Hyperloop enabled) to determine if an iOS advertisement was the cause of the current installation
module.exports = {
hyperloop: {
ios: {
xcodebuild: {
frameworks: [
'iAd'
]
}
}
}
@jkotchoff
jkotchoff / emailed_zip_file_extractor.rb
Created November 29, 2016 00:23
Rails example of how to connect to the Gmail API using Ruby and download a Zip File attachment and then unzip contents from the zip archive
class EmailedZipFileExtractor
# This class downloads an email from gmail and extracts a file out of a .zip attachment
require 'google/apis/gmail_v1'
require 'googleauth'
require 'zip'
# These credentials come from creating an OAuth Web Application client ID
# in the Google developer console
#
@jkotchoff
jkotchoff / generate_twitter_bearer_token.rb
Last active April 27, 2023 23:10
Send Tweets to the Twitter API with an OAuth1 token
# Generate and use an oauth2 bearer token for the Twitter API in Ruby
#
# For Application-Only authentication to the twitter API, a 'bearer token'
# is required to authenticate agains their endpoints for rate limiting
# purposes.
#
# This script generates a bearer token by posting to twitter and then it
# uses that token to poll their API.
#
# Note, the base 64 encoded consumer credentials for the bearer token needs
@jkotchoff
jkotchoff / listview_pullview_ios_extend_edges.js
Last active August 29, 2015 14:13
Using the titanium Listview with a pullView example on an iOS window with extendEdges set to Ti.UI.EXTEND_EDGE_TOP
var win = Ti.UI.createWindow({title: 'listview test', backgroundColor: 'white', extendEdges: [Ti.UI.EXTEND_EDGE_TOP]});
var listView = Ti.UI.createListView({height:'90%', top:0});
var sections = [];
var TOP_OFFSET = 64;
listView.setContentInsets({top:TOP_OFFSET}, {animated:false});
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
{properties: { title: 'Apple'}},
@jkotchoff
jkotchoff / aws_sns_push_notification.rb
Last active February 24, 2021 00:57
Sends a push notifications to an iOS and an Android device from Amazon SNS V2
require 'rubygems'
require 'aws-sdk'
# This code snippet sends a push notification to a device using the Amazon SNS service.
#
# It is using the preview V2 amazon gem as per:
# https://aws.amazon.com/sdk-for-ruby/
#
# This was installed using:
# $ gem install aws-sdk --pre
@jkotchoff
jkotchoff / urban_airship_device_token_export.rb
Created December 23, 2014 22:21
Export device tokens from Urban Airship
require 'rubygems'
require 'urbanairship'
require 'httparty'
Urbanairship.application_key = '...'
Urbanairship.application_secret = '...'
Urbanairship.master_secret = '...'
response = Urbanairship.device_tokens
# This class shows uses version 0.28.7 of the ruby google-api-client gem circa April 2019
# to query the Google Play subscription API.
#
# If using an older version of the google-api-client gem (ie. version 0.8.x), instead refer to:
# https://gist.github.com/jkotchoff/e60fdf048ec443272045/e3e2c867633900d9d6f53de2de13aa0a0a16bb03
#
# Sample usage:
#
# package_name = 'com.stocklight.stocklightapp'
# product_id = 'com.stocklight.stocklight.standardsubscription'
@jkotchoff
jkotchoff / titanium_tablet_check.js
Created October 25, 2013 02:37
This is an edit of: http://www.libtronics.com/2013/10/determining-if-device-is-tablet-on.html that can be used to check whether an appcelerator Titanium app should be rendered with a tablet layout.
function isTablet(){
if(!Ti.Android){
return Ti.Platform.osname === 'ipad';
}
// http://www.libtronics.com/2013/10/determining-if-device-is-tablet-on.html
var height = Ti.Platform.displayCaps.platformHeight;
var width = Ti.Platform.displayCaps.platformWidth;
if (height < width){
var w_inch = height / Ti.Platform.displayCaps.xdpi;