Skip to content

Instantly share code, notes, and snippets.

@pmarques
pmarques / awscli-snippets.sh
Last active December 7, 2017 20:03
Useful AWS CLI snippets
# Delete buckets tagged with a key
for bucket in `aws --profile mojintegration s3api list-buckets --query "Buckets[].Name" --output text` ; doecho -n "Bucket: [${bucket}]: " ; [ "$(aws --profile mojintegration s3api get-bucket-tagging --bucket "${bucket}" --query 'TagSet[?Key==`pm` && Value==`works`].Key' --output text 2>/dev/null)" == "pm" ] && echo -e "\033[31mdelete\033[0m" || echo -e "\033[32mkeep\033[0m" ; done
# Delte old logstreams from a logGroup
LOG_GROUP=a
for streamName in $(aws --profile mojintegration logs describe-log-streams --log-group-name "${LOG_GROUP}" --query 'logStreams[?lastIngestionTime <= `1502092833000`].logStreamName' --output text) ; do aws --profile mojintegration logs delete-log-stream --log-group-name "${LOG_GROUP}" --log-stream-name "${streamName}" ; done
# Delte log grouos which name starts with <LOG_GROUP>
for logGroup in $(aws --profile mojintegrations logs describe-log-groups --query "logGroups[?starts_with(logGroupName, \`${LOG_GROUP}\`)].logGroupName" --output text) ; d
@ptgamr
ptgamr / react-native-deployments.md
Last active November 20, 2018 21:59
Environment configurations for React Native App

Intro

If you ever need a mobile application, you probably have an API endpoint to talk to. And if you're doing it right, you should have different environment for your API, usually it'll be: dev, staging, production.

The problem: How do we do the testing for our app?

We dont' want to perform test againts the production API. We need a way to teach our app to talk to different API environment. But what is the switch?

The naive way:

@marcelog
marcelog / buildspec.yml
Created April 2, 2017 15:44
Example for buildspec file for Amazon CodeBuild and Amazon CodePipeline to achieve Continuous Integration and Continuous Delivery for a ServerLess project
version: 0.1
phases:
install:
commands:
- printenv
- npm install
build:
commands:
- npm run build
@andreaantonioni
andreaantonioni / ios-cell-registration-swift.md
Last active July 15, 2021 13:41 — forked from gonzalezreal/ios-cell-registration-swift.md
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func register(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String)
public func register(_ nib: UINib?, forCellReuseIdentifier identifier: String)
localeIdentifier Description
eu Basque
hr_BA Croatian (Bosnia & Herzegovina)
en_CM English (Cameroon)
en_BI English (Burundi)
rw_RW Kinyarwanda (Rwanda)
ast Asturian
en_SZ English (Swaziland)
he_IL Hebrew (Israel)
ar Arabic
class SignUpMixin(object):
"""
Mixin for the common SignUp methods
"""
permissions = []
profile_serializer = None
group_name = None
def create_token(self, user):
return Token.objects.create(user=user)
@ashishkakkad8
ashishkakkad8 / AFWrapper.swift
Last active January 13, 2020 07:08
Alamofire - SwiftyJSON Wrapper
//
// AFWrapper.swift
// AFSwiftDemo
//
// Created by Ashish on 10/4/16.
// Copyright © 2016 Ashish Kakkad. All rights reserved.
//
import UIKit
import Alamofire
@jimrutherford
jimrutherford / CrashlyticsDestination.swift
Created December 10, 2015 21:00
SwiftyBeaver Crashlyitcs Log Destination
//
// CrashlyticsDestination.swift
//
// Created by Jim Rutherford on 2015-12-10.
//
import UIKit
import Crashlytics
public class CrashlyticsDestination: BaseDestination {
@frontenddeveloping
frontenddeveloping / fetch-api-wrapper.js
Created October 14, 2015 09:26
Simple fetch API wrapper
(function(global) {
'use strict';
var JSON_TYPE_NAME = 'type';
function getQueryString(queryParams) {
var params = Object.keys(queryParams).map(function(paramName) {
return [paramName, encodeURIComponent(queryParams[paramName])].join('=');
});
return '?' + params.join('&');
@bryanrsmith
bryanrsmith / fetch-client.js
Last active April 12, 2020 16:21
A thin wrapper library around the fetch API to provide application-wide HTTP client configuration
export class HttpClient {
constructor(defaults) {
this.defaults = defaults;
this.interceptors = [];
this.activeRequestCount = 0;
this.isRequesting = false;
}
addInterceptor(interceptor) {
this.interceptors.push(interceptor);