Skip to content

Instantly share code, notes, and snippets.

@PaulChana
PaulChana / PrintEmoji.cpp
Last active April 10, 2018 08:14
[Print emoji] Print an emoji in terminal #emoji #cpp #terminal
#include <iostream>
#include <string>
int main()
{
// Here are some emojis...
// https://apps.timwhitlock.info/emoji/tables/unicode
std::string bee = "\U0001F41D"; // Remember this must be 8 bytes total
std::cout << "To " + bee + " or not to " + bee + " that is the " + question<< std::endl;
return 0;
@PaulChana
PaulChana / XCode.xcconfig
Last active February 27, 2018 09:17
[XCode env variables] XCode environment options for xcconfig #xcode
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = <USERNAME>
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@PaulChana
PaulChana / demangle_name.cpp
Last active February 15, 2018 09:26
[Demangle C++ types] Demangle #C++
#include <memory>
#include <string>
#include <cxxabi.h>
class Demangler
{
public:
template <class T>
static std::string compute_object_name (T& obj)
@PaulChana
PaulChana / ReturnToStartOfLine.sh
Created January 22, 2018 12:17
[Return to start of line] Return to the start of the command line #bash #shell
returnToStartOfLine()
{
printf "\b\r"
}
@PaulChana
PaulChana / TrapBashSignal.sh
Created January 22, 2018 10:44
[Bash Traps] Trap signals in bash #shell #bash
# !/bin/sh
function cleanup() {
rm -rf "${BUILD_DIR}"
rm -f "${LOCK_FILE}"
# get rid of /tmp detritus, leaving anything accessed 2 days ago+
find "${BUILD_DIR_BASE}"/* -type d -atime +1 | rm -rf
echo "cleanup done"
}
trap cleanup TERM INT QUIT
@PaulChana
PaulChana / BashDefaults.sh
Created January 22, 2018 10:43
[Bash Defaults] Set variable defaults #shell #bash
#!/bin/bash
FIRST_ARG="${1:-no_first_arg}"
SECOND_ARG="${2:-no_second_arg}"
THIRD_ARG="${3:-no_third_arg}"
echo ${FIRST_ARG}
echo ${SECOND_ARG}
echo ${THIRD_ARG}
@PaulChana
PaulChana / ShowHideCursors.sh
Last active January 22, 2018 12:19
[Bash cursors] Show hide bash cursors #bash #shell
showCursor()
{
tput cnorm
}
hideCursor()
{
tput civis
}
@PaulChana
PaulChana / RoundFloatToInt.sh
Created January 17, 2018 12:10
[RoundFloatToInt] Round a float to int in shell #shell #bash
printf "%.0f" 2743410360.320
@PaulChana
PaulChana / BashColsAndRows.sh
Created January 17, 2018 12:08
[bash cols and rows] Get number of rows and cols #bash #shell
tput lines # outputs the number of lines of the present terminal window.
tput cols # outputs the number of columns of the present terminal window.
@PaulChana
PaulChana / BashSpinner.sh
Created January 17, 2018 11:07
[Bash spinner] Display a progress spinner in bash #shell #bash
spinner="/-\|"
index=1
printf "\b${spinner:index++%${#spinner}:1}"