Skip to content

Instantly share code, notes, and snippets.

View sharat's full-sized avatar

Sarath C sharat

View GitHub Profile
@sharat
sharat / gist:9edf293950e4785663e58aecbdac9b95
Last active August 11, 2023 06:33
Delete GitHub Workflow Runs based on status using GitHub CLI
# Filters the runs based on the status such as failure, cancelled etc.,
# Filter its `databaseId` with JSON fields, extract the value using `jq` then pipe it to delete
gh run list --status=failure --json databaseId --jq '.[] | .databaseId' | xargs -I {} gh run delete {}
@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);
@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 / 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)
}
}
@sharat
sharat / upgrade.sh
Created April 17, 2019 04:18
Bash script to upgrade brew, npm global packages, ruby gems and Cocoapods
echo "Upgrading Brew Packages"
brew upgrade
brew cleanup
echo "Upgrading Global NPM Packages"
npm upgrade -g
echo "Upgrading Gems installed"
gem update
gem cleanup

Keybase proof

I hereby claim:

  • I am sharat on github.
  • I am sarat (https://keybase.io/sarat) on keybase.
  • I have a public key ASCpGYABrDuEUseVITGhBcuQttuLgnVIUdMBtI1yIRQF7Qo

To claim this, I am signing this object:

@sharat
sharat / slack-sidebar-themes
Last active June 26, 2018 19:10
Slack Sidebar Colors - Visual Studio Code Dark
# VS Code Dark theme default
#1E1E1E,#2A2D2E,#094771,#FFFFFF,#2A2D2E,#FFFFFF,#007ACC,#DB6668
# Visual Studio Mac Light
#f3f3f3,#E7E7E7,#e7e7e7,#535353,#e7e7e7,#67018f,#A939DB,#DB6668
# Microsoft Docs
#1a1a1a,#0070da,#00a0f7,#cccccc,#2E2E2E,#FFFFFF,#00a0f7,#DB6668
@sharat
sharat / list-port-process.sh
Created June 25, 2018 21:08
List the process owns a given port
# Change 80 to your desired port.
# Use Sudo as appropriate
sudo lsof -i :80
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 / 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')