Skip to content

Instantly share code, notes, and snippets.

View nathanchere's full-sized avatar
💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained

Nathan Chere nathanchere

💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained
View GitHub Profile
@nathanchere
nathanchere / combine.bat
Last active September 11, 2017 13:57
Batch file for converting between video containers with ffmpeg
Usage: combine.bat mp4 m4a mkv
will combine all mp4 and m4a files into mkv containers
Assumes same file names other than extensions
for %%f in (*.%1) do call ffmpeg -i "%%~nf.%1" -i "%%~nf.%2" -vcodec copy -acodec copy "%%~nf.muxed.%3"
@nathanchere
nathanchere / check_package_installed.sh
Last active May 30, 2017 12:39
Check if a package is installed or not in Arch
#!/usr/bin/env bash
packageName="libssl"
pacman -Qi "$packageName" &> /dev/null
if [ $? -eq 0 ]; then
echo "Package '$packageName' is installed"
fi
@nathanchere
nathanchere / README.md
Created April 20, 2017 08:44
Inject git info into your builds

Use this as a pre-build step, either as part of your TeamCity/TFS/etc process or by adding it to the pre-build step of your project, like the following example. Assuming you have the script saved in a directory build located in the same directory as your .sln file:

<Project> 
  <!-- usual other stuff here //-->
  <!-- ... //-->
  <PropertyGroup>
    <PreBuildEvent>powershell -ExecutionPolicy RemoteSigned -File  $(SolutionDir)build\gitinject.ps1 $(ProjectDir)</PreBuildEvent>
@nathanchere
nathanchere / test.sh
Created April 4, 2017 10:04
Check if current script is running in the foreground or background
#!/bin/bash
if [ -z `ps -o stat= | tail -n 1 | grep +` ]; then
echo 'Running in background!'
else
echo 'Running in foreground!'
fi
@nathanchere
nathanchere / install_vivaldi.sh
Created March 22, 2017 14:37
Install Vivaldi browser (latest) on RPM-based Linux distros
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root. Try sudo ./install_vivaldi.sh"
exit 1
fi
latestVivaldiRpmUrl() {
echo $(curl -sL "https://vivaldi.com/download" | grep "https.*vivaldi-stable-.*.x86_64.rpm" | cut -d '"' -f 4)
}
@nathanchere
nathanchere / install-polybar-ex.sh
Last active September 8, 2020 10:11
Build Polybar on Fedora-ish systems
#!/usr/bin/env bash
# Builds Polybar on Fedora-based systems
# Tested on Fedora 25, Fedora 26 and Korora 25, untested on others
# To get started:
#
# wget -O- https://gist.githubusercontent.com/nathanchere/22491daf4f917b100a35e5c284a5fec5/raw/install-polybar-ex.sh | bash
sudo dnf install -y cmake @development-tools gcc-c++ i3-ipc jsoncpp-devel alsa-lib-devel wireless-tools-devel libmpdclient-devel libcurl-devel cairo-devel xcb-proto xcb-util-devel xcb-util-wm-devel xcb-util-image-devel
@nathanchere
nathanchere / tale of two stacks.ex
Created October 10, 2016 12:00
HackerRank CCTI data structures 06
# HackerRank "Cracking The Coding Interview" - Data Structures (Queues) - A Tale of Two Stacks
defmodule Solution do
def process_commands(counter, queue) when counter == 0, do: nil
def process_commands(counter, queue) do
command = IO.gets("")
|> String.strip
|> process_command(counter - 1, queue)
end
531939670
962555304
962555304
962555304
640552640
640552640
640552640
640552640
640552640
709565753
public static Stream AsStream(this string input)
{
var result = new MemoryStream();
using (var writer = new StreamWriter(result)) {
writer.Write(input);
}
result.Position = 0;
return result;
}
@nathanchere
nathanchere / mp3_info.ex
Created May 10, 2016 12:23 — forked from kommen/mp3_info.ex
Compute MP3 variable bitrate file duration with Elixir
defmodule Mp3Info do
def duration(data) do
compute_duration(data, 0, 0)
end
defp compute_duration(data, offset, duration) when byte_size(data) > offset do
case decode_header_at_offset(offset, data) do
{:ok, length, {samplerate, samples}} ->
compute_duration(data, offset + length, duration + (samples / samplerate))