Skip to content

Instantly share code, notes, and snippets.

View amratab's full-sized avatar

Amrata Baghel amratab

View GitHub Profile
@amratab
amratab / heroku_multiple_remotes_multiple_branches
Created May 30, 2017 04:30
Adding multiple heroku apps to a single repository different branches
Suppose you have two heroku remote apps
myapp-dev & myapp-prod
and two git branches
master(for dev) & production
Now lets setup heroku on the existing git repo in your local machine
Assuming the branches and the apps exist already
git remote add heroku-myapp-dev https://git.heroku.com/myapp-dev.git
git remote add heroku-myapp-prod https://git.heroku.com/myapp-prod.git
Adwords controls metrics for a normal adwords account.
for adwords, first setup a MCC/adwords manager account -- https://adwords.google.com/home/tools/manager-accounts/
Add the client account in this one using https://support.google.com/adwords/answer/6139186?hl=en#link
From the MCC account, create a developer token and apply for a basic token...its easy...not much required...
Now, for the development part
Use this library: https://github.com/googleads/google-api-ads-ruby/tree/master/adwords_api
Use this wiki: https://github.com/googleads/google-api-ads-ruby/wiki/API-access-using-own-credentials-%28installed-application-flow%29
Create OAuth2 credentials for the client account(NOT THE MCC ACCOUNT) using https://developers.google.com/adwords/api/docs/guides/authentication#installed
and running setup_auth2.rb
Run and get results.
@amratab
amratab / renew_letsencrypt.txt
Created December 30, 2016 06:56
Renew lets encrypt certificates
cd /usr/local/sbin
certbot-auto renew
sudo service nginx reload
https://www.natashatherobot.com/ios-autolayout-scrollview/
class ScrollTestViewController: UIViewController {
@IBOutlet weak var contentView: UIView!
@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
let containerViewBounds = contentView.bounds
scrollView.contentSize=CGSizeMake(containerViewBounds.size.height + 20,containerViewBounds.size.width + 20)
import UIKit
import Stripe
class PaymentViewController: UIViewController, STPPaymentCardTextFieldDelegate {
var paymentTextField: STPPaymentCardTextField!
var saveButton: UIButton!
var saveAction: UIAlertAction!
override func viewDidLoad() {
@amratab
amratab / adding_custom_items_to_UIAlertController
Created May 30, 2016 16:49
adding custom buttons etc to alerts
@IBAction func showAlertButtonTapped(sender: UIButton) {
// create the alert
let alertController = UIAlertController(title: "Add Card", message: "Add your card details here and hit save\n\n\n", preferredStyle: UIAlertControllerStyle.Alert)
// alertController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width-20, 400)
// let margin:CGFloat = 8.0
// let rect = CGRectMake(margin, margin, alertController.view.bounds.size.width - margin * 4.0, 44)
// let customView = UIView(frame: rect)
paymentTextField.frame = CGRectMake(5, 75, alertController.view.bounds.size.width - 150, 44)//
Select the Info.plist file.
Click on the + button to add a key.
Add the key named NSLocationAlwaysUsageDescription.
Write a convincing description of why you need location in the background.
class MovieDetailViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var mapView: MKMapView!
var locations = [MKPointAnnotation]()
lazy var locationManager: CLLocationManager! = {
// for standard dialog which does not take text
let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.quote = self.movie.overview
content.contentURL = NSURL(string: "https://www.themoviedb.org/movie/271110-captain-america-civil-war?language=en")
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)
// for dialog to open inside app..can include text and image
let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentTitle = self.movie.title
var player: AVQueuePlayer!
//for sound of assets let sound = NSDataAsset(name: "audio")
func viewDidLoad() {
let session = AVAudioSession.sharedInstance()
try! session.setCategory(AVAudioSessionCategoryPlayAndRecord)
let item = AVPlayerItem(URL: NSURL(string: "http://incompetech.com/music/royalty-free/mp3-royaltyfree/Motherlode.mp3")!)
let item2 = AVPlayerItem(URL: NSURL(string: "http://incompetech.com/music/royalty-free/mp3-royaltyfree/Vicious.mp3")!)
player = AVQueuePlayer(items: [ item, item2])
player.actionAtItemEnd = .Advance