Skip to content

Instantly share code, notes, and snippets.

View amitpdev's full-sized avatar

Amit Palomo amitpdev

View GitHub Profile
@amitpdev
amitpdev / generate_android_release.sh
Created August 9, 2017 17:15
Generate a signed APK for Android with React Native
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <certificate_key.jks>"
exit 1
fi
function loginfo {
GREEN="\033[92m"
CLEAR="\033[0m"
@amitpdev
amitpdev / MapScreen.js
Last active July 18, 2017 21:24
React Native Map Region Persistency - Save and Restore the last region on the map set by your user
import React from 'react'
import { View, StyleSheet, AsyncStorage } from 'react-native'
import MapView from 'react-native-maps'
const DEFAULT_REGION = {
latitude: 32.068185,
longitude: 34.778051,
latitudeDelta: 0.045,
longitudeDelta: 0.045,
}
@amitpdev
amitpdev / CloudinaryManager.js
Last active April 9, 2017 19:14
A simple Singleton for Cloudinary on ES6 JS
import * as cloudinary from 'cloudinary-core';
class CloudinaryManager {
static get shared() {
if (this.instance == null || this.instance == undefined) {
this.instance = cloudinary.Cloudinary.new();
this.instance.config('cloud_name', 'mycloudname');
}
return this.instance;
}
@amitpdev
amitpdev / gist:351ef852674d909c0f6e09bca057ec82
Created January 31, 2017 15:29
A nice example for writing a "multi-dimensional" enum with Swift
enum HomeStatus: Int {
case pending = 1
case active = 2
case inactive = 3
case deleted = 4
var title: String {
switch self {
case .pending:
@amitpdev
amitpdev / adjust_gpx_to_apple_format.awk
Created September 16, 2015 17:17
Use this awk script to adjust standard GPX files downloaded from any site (bikes) into a GPX format that is supported by Xcode.
awk '
BEGIN {
buffer=""
}
{
gsub(/<\/*trk>/,"",$0)
gsub(/<\/*trkseg>/,"",$0)
gsub(/<trkpt/,"<wpt", $0)
gsub(/<\/trkpt>/,"<\/wpt>", $0)
print
@amitpdev
amitpdev / gist:4c7ce1738f25ace2167f
Created April 27, 2015 15:13
Git release notes
#!/usr/bin/env bash
relnotes() {
local from_ref=$1
if [ "$#" -eq 2 ]; then
local to_ref=$2
elif [ "$#" -eq 1 ]; then
local to_ref="HEAD"
else
echo "Usage: relnotes <from-ref> [<to-ref>]"
@amitpdev
amitpdev / gist:8317162
Created January 8, 2014 14:02
Regex tester for command line
perl -e '"My wonderfull string 123123" =~ m/\d+/; print "$& \n"'
@amitpdev
amitpdev / gist:5593016
Created May 16, 2013 16:26
UIButton with custom image in place of UITable's accessoryView ( right arrow > )
// Add a MAP button in place of the cell's accessoryView
UIImage *image = [UIImage imageNamed:@"checkin-fb-place.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
UIButton *mapButton = [[UIButton alloc] initWithFrame:imageView.frame];
[mapButton setImage:image
forState:UIControlStateNormal ];
[mapButton addTarget:self action:@selector(mapAction:)
forControlEvents:UIControlEventTouchDown];
cell.accessoryView = mapButton;
[imageView release];
@amitpdev
amitpdev / gist:5541207
Created May 8, 2013 15:24
samba mount
mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/ntserver
@amitpdev
amitpdev / gist:5502495
Created May 2, 2013 14:15
xargs in OSX
find . -iname *something* | xargs -I {} mv {}