This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$websites = [ | |
["uid" => "mywebsite01", "name" => "mywebsite01.dev", "alias"=>"www.mywebsite01.dev", "root" => "/var/www/mywebsite01/www"], | |
["uid" => "mywebsite02", "name" => "mywebsite02.dev", "alias"=>"", "root" => "/var/www/mywebsite02/www"] | |
]; | |
$template = | |
" nxv__UID_: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Format a float value with desired numbers after the comma to a string. Doesn't display the comma if the number is a round value. | |
import Foundation | |
extension Double { | |
func toDecimalString(decimals: Int = 0) -> String { | |
let format = (self % 1 > 0 && decimals > 0) ? "%.\(decimals)f" : "%.0f" | |
return String(format:format, self) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let high1 = 1000 | |
let low1 = 200 | |
let high2 = 250 | |
let low2 = 10 | |
let value = 200 | |
let remapedValue = low2 + (value - low1) * (high2 - low2) / (high1 - low1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias_stats() { | |
local search="$1" | |
list=""; for c in $(alias | grep "$search" | cut -d'=' -f1); do count=$(grep -Ec ";$c" ~/.zsh_history); list="${list}\n${count} ${c}"; done; echo -e $list | sort -n | grep -Ev "^0" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some useful Shell aliases and function for using on Mac OS X | |
# https://gist.github.com/atika/4bca2820b21a71858a06 | |
# Regular Expressions | |
ipregx="[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}" # IP Regular Expression | |
mailregx="[a-zA-Z0-9_-\.]+@[a-zA-Z0-9_-\.]+\.[a-z]{2,3}" # Mail Regular Expression | |
# ql : Show a "Quick Look" view of files | |
ql () { /usr/bin/qlmanage -p "$@" >& /dev/null & } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tz = NSTimeZone.init(forSecondsFromGMT:3600) | |
NSTimeZone.setDefaultTimeZone(tz) // Change app default timezone | |
print(tz) // GMT+0100 (UTC+1) offset 3600 | |
print(NSDate()) // 2016-03-10 09:57:44 +0000 | |
print(tz.abbreviation) // Optional("UTC+1") | |
print(tz.name) // GMT+0100 | |
print(tz.description) // GMT+0100 (UTC+1) offset 3600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The first script tag is optional if you start with javascript | |
//<script> | |
$(document).ready(function () { | |
$("body").append("<br>jQuery said AngularJS rocks!"); | |
alert($(document).html()); | |
}); | |
angular.module('PricesApp', []) | |
.controller("PriceController", function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pathname' | |
imgURLRegex = /^(!\[.*?\]\()([^\s\)]*)(\s*.*\))/ | |
rootsPaths = [ | |
'/Users/username/Path/To/hexo/source/', | |
'/Another/PathTo/Website/Directory/' | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Write category for an app | |
developer="public.app-category.developer-tools" | |
utilities="public.app-category.utilities" | |
productivity="public.app-category.productivity" | |
photography="public.app-category.photography" | |
video="public.app-category.video" | |
music="public.app-category.music" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verify_programs() { | |
local programs="$1" | |
local ccyan="\\033[1;36m" | |
local cnormal="\\0033[0;39m" | |
abort=0 | |
for p in $programs; do | |
type $p >/dev/null 2>&1 || { echo -e >&2 " ${ccyan}${p}${cnormal} required but it's not installed. Aborting."; abort=1; } | |
done | |
if [[ $abort -eq 1 ]]; then | |
exit 1; |