Skip to content

Instantly share code, notes, and snippets.

View sharat's full-sized avatar

Sarath C sharat

View GitHub Profile
@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
@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 / 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 / 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 / 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 / ipaddrescheck.cpp
Created December 12, 2012 04:20
Check the given IP address is in IPv6 or v4 format (windows version)
// Change the headefile for Windows
#include <memory>
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib,"Ws2_32.lib");
#include <string>
using namespace std;
// This is compatible with old version of Windows.
bool IsIPAddress(const string& value)
@sharat
sharat / gitsnippets.sh
Created December 7, 2012 15:02
Useful git commands
# 1. Reset the modifications
git checkout -- <filename>
@sharat
sharat / MemoryInfo.cs
Created October 23, 2012 11:14
Memory Info in C#
public static class MemoryInfo
{
[DllImport("psapi.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);
[StructLayout(LayoutKind.Sequential)]
public struct PerformanceInformation
{
public int Size;
@sharat
sharat / radix-sort.cpp
Created October 19, 2012 06:34
radi sort
void radix_sort(unsigned *begin, unsigned *end)
{
unsigned *begin1 = new unsigned[end - begin];
unsigned *end1 = begin1 + (end - begin);
for (unsigned shift = 0; shift < 32; shift += 8) {
size_t count[0x100] = {};
for (unsigned *p = begin; p != end; p++)
count[(*p >> shift) & 0xFF]++;
@sharat
sharat / SysInfoHelper.cs
Created October 17, 2012 10:31
Get the operating system information using C#
using System.Management;
using System.Security.Principal;
using Microsoft.Win32;
public class SysInfoHelper
{
public static void LogSystemInfo(int messageID)
{
LogOSVersionInfo(messageID);
LogUserInfo(messageID);