Skip to content

Instantly share code, notes, and snippets.

View aksswami's full-sized avatar

Amit Kumar Swami aksswami

  • Accellion
  • Singapore
View GitHub Profile
@aksswami
aksswami / index.html
Created September 18, 2014 07:57
Navigation functions (heading) // source http://jsbin.com/fepisositinu/1
<!DOCTYPE html>
<html>
<head>
<title>Navigation functions (heading)</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
@aksswami
aksswami / Git Mergetool (p4merge).md
Last active May 3, 2017 07:17
p4merge as git mergetool

To setup p4merge (3 way merge) as your default mergetool brew cask install p4merge And paste below text in your global .gitconfig file. Which can be found in your home directory.

[merge]
 keepBackup = false
   tool = p4merge
[mergetool "p4merge"]
   cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
keepTemporaries = false
@aksswami
aksswami / GmailParser.gs
Created May 4, 2017 11:43
This Google App script parse gmail messages with specific label and put them a spreadsheet in your drive. I am using Gmail filter to put label to these message and remove this label after parsing to only parse new message on every turn.
function searchMessageWithLabel() {
var labelName = "My Label";
var response = GmailApp.search("label:" + labelName);
var label = GmailApp.getUserLabelByName(labelName);
if (response.length == 0) {
Logger.log("No messages available.");
} else {
Logger.log("Messages");
for(var i = 0; i < response.length; i++) {
class Marathon < Formula
desc "Marathon makes it easy to write, run and manage your Swift scripts 🏃"
homepage ""
url "https://github.com/aksswami/Marathon/archive/v0.0.1.tar.gz"
sha256 "44d5431af1d16df65f01ee9fc6e08cf73d94812cda611d3b5c518760d4a8bfa1"
def install
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
@aksswami
aksswami / remove_image_background.sh
Last active May 6, 2017 13:46
Bash script tp remove image background and make it transparent. (For multiple images)
#!/bin/bash
for i in $( ls | grep 'loading_animation' ); do
convert $i -fill none -fuzz 12% -draw "matte 0,0 floodfill" -flop -draw "matte 0,0 floodfill" -flip -draw "matte 0,0 floodfill" -flop -draw "matte 0,0 floodfill" -flip $i
done
@aksswami
aksswami / substring_line.pl
Created May 6, 2017 13:47
Print all the line of a file, which contains a substring.
#!/usr/bin/perl -w
use strict;
use warnings;
# (1) quit unless we have the correct number of command-line args
my $num_args = $#ARGV + 1;
if ($num_args != 1) {
print "\nUsage: name.pl <FILE_PATH>\n";
exit;
}
$ chflags -R nouchg /Users/XXX/Developer/iOSWorkSpace/swift-source-compat-suite/project_cache/Moya
$ git -C /Users/XXX/Developer/iOSWorkSpace/swift-source-compat-suite/project_cache/Moya clean -ffdx
Removing Packages/
$ git -C /Users/XXX/Developer/iOSWorkSpace/swift-source-compat-suite/project_cache/Moya rev-parse HEAD
current_sha: 5fd1ac2e54db91e1e30194eb8c74911a5df20ee2
configured_sha: 5fd1ac2e54db91e1e30194eb8c74911a5df20ee2
current_sha == configured_sha
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package -C /Users/XXX/Developer/iOSWorkSpace/swift-source-compat-suite/project_cache/Moya clean
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift build -C /Users/XXX/Developer/iOSWorkSpace/swift-source-compat-suite/project_cache/Moya --verbose --configuration release
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -I /Applications/Xcode.app/Contents/Deve

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@aksswami
aksswami / OSX-Convert-MOV-GIF.md
Created May 14, 2017 12:29 — forked from tskaggs/OSX-Convert-MOV-GIF.md
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@aksswami
aksswami / TypeSafeNotification+Extension.swift
Last active August 20, 2017 19:27
Notification handling in type safe manner.
//
// Notification+Extension.swift
//
//
// Created by Amit Kumar Swami on 20/08/17.
// Copyright © 2017 aks.swami. All rights reserved.
//
import Foundation
import UIKit