Skip to content

Instantly share code, notes, and snippets.

@skatiyar
skatiyar / minheap.go
Created March 15, 2023 18:48
MinHeap
package main
import (
"fmt"
"math"
)
func parent(i int) int {
return (i - 1) / 2
}
@skatiyar
skatiyar / linux-server-setup.sh
Created September 8, 2015 10:01
Basic list of commands to setup new server instance. (Tested only for Ubuntu 12.04) (Taken from digitalocean tutorials.)
# A small set of commands to do basic server setup
# First and foremost add password to root
sudo passwd root
# Update the dist
sudo apt-get update && sudo apt-get upgrade
# Block rogue connections by
# allowing only ssh, port - 80, 443
# using Uncomplicated Firewall (ufw)
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@skatiyar
skatiyar / inspect_element.js
Created May 14, 2014 13:20
An angular directive to inspect elements on remote devices.
'use strict';
angular.module('cafeApp')
.directive('inspect', function($timeout, $http) {
Element.prototype.serializeWithStyles = (function () {
var defaultStylesByTagName = {};
var noStyleTags = {'BASE':true,'HEAD':true,'HTML':true,'META':true,'NOFRAME':true,'NOSCRIPT':true,'PARAM':true,'SCRIPT':true,'STYLE':true,'TITLE':true};