Skip to content

Instantly share code, notes, and snippets.

View sharat's full-sized avatar

Sarath C sharat

View GitHub Profile
@sharat
sharat / convert-line-endings.sh
Created December 13, 2012 18:18
convert the line endings of multiple files in a directory with the help of vi editor.
#Convert from dos/unix to unix
#To convert from any mixture of CRLF endings and LF-only endings, to LF-only endings:[C 1]
:set hidden #Allow modified buffers to be hidden.
:set ffs=dos #Assume dos line endings (CRLF or LF-only) when reading files.
:args *.c *.h #Specify the files to convert.
:argdo set ff=unix|w #For each argument, set unix file format for the buffer, and write the file.[C 2]
#Convert from dos/unix to dos
@sharat
sharat / git-revert-sample
Created September 9, 2014 07:10
How to use git revert?
git-revert $ git init
git-revert (master) $ touch 1.txt
git-revert (master) $ touch 2.txt
git-revert (master) $ git add .
git-revert (master) $ git commit -am "wanted commit 1"
[master (root-commit) 80395aa] wanted commit 1
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1.txt
create mode 100644 2.txt
@sharat
sharat / apns-check-openssl
Created October 9, 2014 15:31
How to check APNS Connectivity?
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert <your.pem> -key <your.pem>
@sharat
sharat / brew-deps.sh
Created July 2, 2015 10:07
Brew dependencies
#zsh
brew list | while read cask; do echo -n "\e[1;34m$cask ->\e[0m"; brew deps $cask | awk '{printf(" %s ", $0)}'; echo ""; done
@sharat
sharat / archive.sh
Created July 27, 2015 12:06
create IPK file using xctool (xcrun)
#!/bin/bash
set -x
# codesigning and provisioning profile should be configured using Xcode
PROJECT=<your project name>
SCHEME=${PROJECT} # Setting project name as the default scheme. Update based on your scheme
ARCHIVEPATH=`pwd`/archive
IPA_NAME=${PROJECT}
PROJECT_BUILDDIR=${ARCHIVEPATH}/${IPA_NAME}.xcarchive/Products/Applications
import json
import logging
import os
import socket
import ssl
import struct
import sys
import time
import uuid
@sharat
sharat / remove-invalid-remote-refs-git.sh
Last active December 15, 2016 12:23
When you local repository fails to remove invalid remote referneces
# The symptoms. When you do this, you keep on getting new and deleted branches all the time
git remote update
git pull
# Symptom 2 (for obvious reasons).
git branch -a --merged # Check the merged branches
git push origin --delete [branch name] # this complains remote doesn't exist
# The remedy
@sharat
sharat / kue-list.js
Created April 21, 2017 06:15
Lists all jobs in Kue
require('dotenv').config()
var kue = require('kue');
console.info('Creating Queue with redis', process.env.REDISCLOUD_URL);
var queue = kue.createQueue({
redis: process.env.REDISCLOUD_URL
})
console.log('moving forward with kue')
extension UITextField {
func useUnderline() -> Void {
let border = CALayer()
let borderWidth = CGFloat(2.0) // Border Width
border.borderColor = UIColor.red.cgColor
border.frame = CGRect(origin: CGPoint(x: 0,y :self.frame.size.height - borderWidth), size: CGSize(width: self.frame.size.width, height: self.frame.size.height))
border.borderWidth = borderWidth
self.layer.addSublayer(border)
self.layer.masksToBounds = true
}
@sharat
sharat / format-time-interval-swift.swift
Last active August 31, 2019 12:53
Format time Interval to hour, minute, second format using Swift
extension TimeInterval {
func stringFormatted() -> String {
let interval = Int(self)
let seconds = interval % 60
let minutes = (interval / 60) % 60
let hours = (interval / (60*60)) % 60
return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
}
}