Skip to content

Instantly share code, notes, and snippets.

View aramboyajyan's full-sized avatar

Aram Boyajyan aramboyajyan

View GitHub Profile
@aramboyajyan
aramboyajyan / dir-exists.go
Created January 12, 2021 07:14
Golang check if target directory exists
func DirExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
} else if os.IsNotExist(err) {
return false, nil
}
return false, err
}
# Create a new note.
new_daily_note() {
cd ~/Documents/DailyNotes
currentDate=$(date '+%Y-%m-%d')
currentTime=$(date '+%H:%M')
fileName="${currentDate}.todo"
if [ -f "$fileName" ]; then
echo "Daily note file ($fileName) already exists."
else
cp _new.todo $fileName
@aramboyajyan
aramboyajyan / .gitignore
Last active March 22, 2024 09:22
.gitignore for WordPress
# Configuration.
/.htaccess
/.htaccess_lscachebak_*
/wp-config.php
/sitemap.xml
/sitemap.xml.gz
# Files in the root.
*.pdf
*.jpg
@aramboyajyan
aramboyajyan / .bash_profile
Created October 31, 2019 00:28
Bash profile
# Run the updates.
alias update="sudo -- sh -c 'apt-get update; apt-get upgrade -y --allow-unauthenticated; apt-get dist-upgrade -y --allow-unauthenticated; apt-get autoremov$
# Colors!
if [ "$TERM" != "dumb" ]; then
[ -e "$HOME/.dir_colors" ] &&
DIR_COLORS="$HOME/.dir_colors" [ -e "$DIR_COLORS" ] ||
DIR_COLORS=""
eval "`dircolors -b $DIR_COLORS`"
alias ls='ls --color=auto'
@aramboyajyan
aramboyajyan / .gitignore
Last active June 27, 2020 15:20
.gitignore for Drupal 7
# Ignore custom settings.
sites/default/settings.local.php
# phpStorm settings.
/.idea/
# Ignore paths that contain user-generated content.
/sites/*/files
/sites/*/private
/files/*
@aramboyajyan
aramboyajyan / .gitignore
Last active September 23, 2022 09:47
.gitignore for Drupal 8 / 9 / 10
# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/
# Ignore sensitive information
@aramboyajyan
aramboyajyan / settings.local.php
Created November 24, 2018 09:14
Local settings for Drupal 8
<?php
/**
* @file
* Development settings.
*
* Created by: Aram Boyajyan
* https://www.aram.cz/
*/
@aramboyajyan
aramboyajyan / selectable-draggable.js
Created May 26, 2018 13:08
Combining jQuery UI selectable and draggable
$(function () {
'use strict';
var selected = $([]), offset = {top: 0, left: 0};
$("#container").selectable();
$("#container div").draggable({
snap : true,
start: function () {
if (!$(this).is(".ui-selected")) {
$(".ui-selected").removeClass("ui-selected");
}
@aramboyajyan
aramboyajyan / quick-drupal-8.make
Created March 8, 2018 23:46
Drupal 8 make file
core = 8.x
api = 2
projects[] = drupal
projects[level1][type] = profile
projects[level1][download][type] = git
projects[level1][download][url] = https://github.com/aramboyajyan/d8level1
projects[seven_improved][type] = theme
projects[seven_improved][download][type] = git
@aramboyajyan
aramboyajyan / snippet.php
Created August 18, 2016 19:11
Format number of seconds to HH:MM:SS.
function format_duration($seconds) {
$time = round($seconds);
// Check if video length is longer than 1 hour. If not, we will skip the hour
// numbers.
if ($seconds > 60 * 60) {
$formatted = sprintf('%02d:%02d:%02d', ($time / 3600), ($time / 60 % 60), $time % 60);
}
else {
$formatted = sprintf('%02d:%02d', ($time / 60 % 60), $time % 60);