Skip to content

Instantly share code, notes, and snippets.

View epcim's full-sized avatar

Petr Michalec epcim

View GitHub Profile
@epcim
epcim / ask.sh
Created June 7, 2018 10:10
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://djm.me/ask
local prompt default reply
while true; do
@epcim
epcim / git-branches-by-commit-date.sh
Created June 5, 2018 07:36 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@epcim
epcim / convert-csv-to-json.rb
Created May 28, 2018 08:15 — forked from X0nic/convert-csv-to-json.rb
Convert a csv to json
#! /usr/bin/env ruby
require 'csv'
require 'json'
csv = CSV.parse(File.read(file_name).scrub, headers: true)
hash = csv.map{ |row| { code: row["Classification Code"], description: row["Classification Code Description English"] } }
json = hash.to_json
@epcim
epcim / git-rsync
Created May 25, 2018 06:45 — forked from matthieuprat/git-rsync
Sync a local Git work tree with a remote one
#!/bin/sh
#
# Author: Matthieu Prat <[email protected]>
# Date: 01/22/2015
#
# Sync a local work tree with a remote one.
# It's rsync on steroids within large Git repositories.
USAGE='<repository>'
LONG_USAGE='Sync a local work tree with a remote one.'
@epcim
epcim / supermicro-ipmi-mac-address.md
Created May 16, 2018 10:17 — forked from DavidWittman/supermicro-ipmi-mac-address.md
Pull the LAN1/eth0 MAC address from SuperMicro IPMI

You can find the MAC address for LAN1/eth0 (not the BMC MAC) via the SuperMicro IPMI interface by running the following command:

$ ipmitool -U $IPMI_USER -P $IPMI_PASS -H $IPMI_HOST raw 0x30 0x21 | tail -c 18

The eth0 MAC address will be output in this format:

00 25 90 f0 be ef
import pdb; pdb.set_trace() # NOCOMMIT
@epcim
epcim / dict_merge.py
Created February 15, 2018 10:08 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
@epcim
epcim / react-native-ultisnip.snippet
Created February 6, 2018 21:05 — forked from igolden/react-native-ultisnip.snippet
React Native snippets for vim and ultisnip
snippet rnccf
import React, { PropTypes } from 'react'
import { View, StyleSheet, Text } from 'react-native'
$1.propTypes = {
}
export default function ${1:FunctionName} (props) {
return (