Skip to content

Instantly share code, notes, and snippets.

View dunada's full-sized avatar

Eduardo Rodrigues Gomes dunada

View GitHub Profile
@lambrospetrou
lambrospetrou / awslogs.config
Last active November 7, 2023 13:58
Custom CloudWatch Logs agent configuration file for Elastic Beanstalk AL2
###################################################################################################
#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
#### except in compliance with the License. A copy of the License is located at
####
#### http://aws.amazon.com/apache2.0/
####
#### or in the "license" file accompanying this file. This file is distributed on an "AS IS"
#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 13, 2025 11:08
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@Edudjr
Edudjr / Luhn.swift
Last active February 15, 2024 20:33 — forked from cwagdev/Luhn.swift
Luhn Algorithm in Swift 4.1
func luhnCheck(_ number: String) -> Bool {
var sum = 0
let digitStrings = number.reversed().map { String($0) }
for tuple in digitStrings.enumerated() {
if let digit = Int(tuple.element) {
let odd = tuple.offset % 2 == 1
switch (odd, digit) {
case (true, 9):
@postpostscript
postpostscript / replify
Last active November 7, 2024 02:47
replify - Create a REPL for any command
#!/bin/sh
command="${*}"
printf "Initialized REPL for `%s`\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "%s> " "$command"
@avneeshroks
avneeshroks / UnivarsalLinkForAndroidAndIosLaunch-Javascript.js
Last active July 12, 2022 03:41
To Have a universal link setup for android and ios device open app if there else open app store
(function() {
var getSegment = function (url, index) {
return url.replace(/^https?:\/\//, '').split('/')[index];
}
var App = function(options) {
this.init(options);
};
App.prototype = {
def getVersionCode(int default_) {
return project.hasProperty('versionCode') ? versionCode.toInteger() : default_
}
def getVersionName(String default_) {
return project.hasProperty('versionName') ? versionName : default_
}
versionCode getVersionCode(3)
versionName getVersionName("1.0")
@mangar
mangar / string_initialize.rb
Created May 8, 2015 13:26
Ruby Colorize Strings
#
#
#
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
@alex-shpak
alex-shpak / Interceptor.java
Last active June 14, 2024 02:40
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@atljeremy
atljeremy / DateUtils.swift
Last active March 26, 2017 18:47
Swift extension on NSTimeInterval and NSDate to make NSDate Comparable and to make working with dates in general more concise
/*
Examples:
var date: NSDate
date = 10.seconds.fromNow
date = 30.minutes.ago
date = 2.days.from(someDate)
date = NSDate() + 3.days
if dateOne < dateTwo {