Skip to content

Instantly share code, notes, and snippets.

View Mahabali's full-sized avatar
🌟
No act of kindness, no matter how small, is ever wasted. Peace ✌️

Mahabali Mahabali

🌟
No act of kindness, no matter how small, is ever wasted. Peace ✌️
View GitHub Profile
@Mahabali
Mahabali / gist:08ae4d77825b68c3cbcd67ae20c33fb7
Created April 1, 2024 19:46
Run through each key in json
const appendRandomStringToKeys = (obj, randomString) => {
const isObject = (val) => typeof val === 'object' && !Array.isArray(val) && val !== null;
Object.keys(obj).forEach((key) => {
if (key !== '_typename' && key !== 'Instrumentquery') {
const newKey = key + randomString;
obj[newKey] = obj[key];
delete obj[key];
if (isObject(obj[newKey])) {
appendRandomStringToKeys(obj[newKey], randomString);
@Mahabali
Mahabali / Regex and test cases
Created February 21, 2022 10:44
Regex Pattern Matching for Indian Phone Numbers
^(?:(?:\+|0{0,2})91(\s*[\ -]\s*)?|[0]?)?[6789]\d{9}|(?:\+)(\d[ -]?){10,12}\d$
//Works for below number formats
//+91 1800 102 4455
//+91 77238 39007
//+91 124-5174055
//07723839007
@Mahabali
Mahabali / gist:64310f94af17a53514476f9b0454bad4
Created December 7, 2018 03:51
Dealing with "error: exportArchive: No "iOS In House" profiles for team" or error: exportArchive: No "adhoc " profiles for team
Below is a common error when trying to setup CI/CD using fastlane or raw XcodeBuild/Xcrun command
"error: exportArchive: No "iOS In House" profiles for team" or error: exportArchive: No "adhoc In House" profiles for team
Fixing it :
1) Easiest way is to make a build archive in Xcode, Export using organizer and Saving it in a folder.
2) Go to the folder, open Export Options.plist and replicate the same in Fastlane - build_app or gym - export options
3) In case of XcodeBuild - Replace the same in Export Options.plist which is provided in XCodeBuild command and try again
4) Make a build, thank me .
@Mahabali
Mahabali / gist:5ff321a8e4090d995403d8794c2d2a6b
Last active August 1, 2018 13:15
Apple Push notification registration
import UserNotifications
if #available(iOS 10.0, *) {
//iOS 10.0 and greater
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert], completionHandler: { granted, error in
DispatchQueue.main.async {
if granted {
UIApplication.shared.registerForRemoteNotifications()
}
@Mahabali
Mahabali / build_ios_libs.sh
Created March 22, 2018 06:43
webrtc build ios libs.sh
#!/bin/bash
# Copyright 2015 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
@Mahabali
Mahabali / String Utils
Created August 26, 2017 09:40
iOS HTML characters decoding
+ (NSString*)decodeHTMLCharacters:(NSString*)sampleUnFormatterString{
if (sampleUnFormatterString == nil || sampleUnFormatterString.length == 0) {
return sampleUnFormatterString;
}
NSString *sampleUnFormatterStringCopy =sampleUnFormatterString;
NSString *regString = [[NSString alloc]initWithFormat:@"&#[0123456789]{2,4};"];
NSError *error=nil;
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:regString
options:0
@Mahabali
Mahabali / Controller.js
Created August 5, 2016 15:26
Long Press Gesture Detection for ionic/Angular JS based frameworks
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}