Skip to content

Instantly share code, notes, and snippets.

View hiulit's full-sized avatar
💻
Working

hiulit

💻
Working
View GitHub Profile
@hiulit
hiulit / open-dev-tools-startup
Last active June 18, 2018 08:15
Open desire folder and dev tools on startup
tell application "<APP_NAME>" to activate
tell application "<APP_NAME>" to activate
tell application "<APP_NAME>" to activate
# Change 'defaultFolder' to your 'Projects' folder.
set defaultFolder to alias "<PATH:TO:FOLDER:>" # Use ':' instead of '/'
set projectFolder to (choose folder with prompt "Select project folder" default location defaultFolder)
set projectFolder to POSIX path of projectFolder
tell application "Terminal"
# Change 'code' for 'sublime' or any text editor.
do script "cd " & projectFolder & " && git pull && code . && history -c"
@hiulit
hiulit / javascript-object-empty-function.js
Created May 16, 2018 13:45
Function to check if a JavaScript Object is empty
function isObjectEmpty(obj) {
for(var key in obj) {
if(obj.hasOwnProperty(key))
return false
}
return true
}
var myObj = {}; // Empty Object
if(isObjectEmpty(myObj)) {
@hiulit
hiulit / sort-array-object.js
Created April 27, 2018 11:29
Simple function to sort an array of objects
function sortByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key];
var y = b[key];
if (typeof x == "string") {
x = (""+x).toLowerCase();
}
if (typeof y == "string") {
y = (""+y).toLowerCase();
}
@hiulit
hiulit / git-auto-complete-macos-terminal.md
Last active June 25, 2018 08:04
Git auto-complete on macOS Terminal

You must have brew installed

  • Open the Terminal and enter brew install bash-completion.
  • Now enter open ~/.bash_profile.
  • At the end of the file paste the code below:
# Bash completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
@hiulit
hiulit / show_git_branch_macos_terminal.md
Last active March 12, 2018 15:32
Show git branch on macOS Terminal
  • Open the Terminal and enter open ~/.bash_profile
  • At the end of the file, paste the code below:
# Git branch in prompt.
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@hiulit
hiulit / xmlstarlet_delete_tag_value.sh
Created February 28, 2018 11:55
xmlstarlet delete tag containing certain value
xmlstarlet ed -L -d "/path/to/tag[contains(text(),'some text')]" "path/to/file"
@hiulit
hiulit / convert_unhyphenated_datetime.sh
Created February 28, 2018 11:53
Convert unhyphenated datetime (20180228T125033) into 2018-02-28T12:50:33
date="$(echo "20180228T125033" | cut --output-delimiter=$'-' -c1-4,5-6,7-8)"
time="$(echo "20180228T125033" | cut --output-delimiter=$'-' -c10-11,12-13,14-15)"
date --utc --date "$date $time" +%s
@hiulit
hiulit / remove-ds_store-files-mac-osx.txt
Created May 29, 2017 08:41
How to Recursively Remove .DS_Store Files on Mac OS X
// Credits https://medium.com/@danilosapad/how-to-recursively-remove-ds-store-files-on-mac-os-x-6c8570c68ad0
* Open Terminal.
* Go to desired folder.
* Type `find . -name *.DS_Store -type f -delete`.
@hiulit
hiulit / flexbox-issues-ie.md
Last active May 18, 2017 09:26
Flexbox issues with IE

Flexbox issues with IE

Inline elements inside flex container don't wrap

display: block;
width: 100%;

Children of flex-column don't adjust height properly

@hiulit
hiulit / WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED.txt
Last active March 24, 2017 23:59
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
ssh-keygen -R "you server hostname or ip"