This file contains hidden or 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 | |
| function convert_to_timezone($date, $timezone, $format = 'Y-m-d H:i:s') { | |
| $object = date_create_from_format($format, $date, timezone_open('UTC')); | |
| date_timezone_set($object, timezone_open($timezone)); | |
| return $object; | |
| } | |
| function convert_to_timezone_string($date, $timezone, $format = 'Y-m-d H:i:s') { |
This file contains hidden or 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
| search-files() { | |
| local folder=$(test $# -eq 2 && echo "$1" || echo .) | |
| local query=$(test $# -eq 2 && echo "$2" || echo "$1") | |
| local IFS=$'\n' | |
| for f in $(find "$folder" -type f); do | |
| local result=$( | |
| cat "$f" | | |
| GREP_COLOR='01;32' egrep --color=always -n "$query" | | |
| GREP_COLOR='01;33' egrep --color=always "^\d+:" |
This file contains hidden or 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
| RED=$(tput setaf 1) | |
| GREEN=$(tput setaf 2) | |
| YELLOW=$(tput setaf 3) | |
| WHITE=$(tput setaf 7) | |
| NORMAL=$(tput sgr0) | |
| _git-branch() { | |
| local branch="$(git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///')" | |
| test "x$branch" != x && echo " ($branch)" | |
| } |
This file contains hidden or 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
| # Ubuntu: apt-get intall entr | |
| jslint-watch() { | |
| local folder=$(test "x$1" != x && echo "$1" || echo .) | |
| local files="find $folder -type f -name '*.js'" | |
| local modified='$('"$files"' -printf "%T+ %p\n" | sort -r | head -1 | cut -d" " -f2)' | |
| eval $files | entr sh -c 'jslint '"$modified"' --color' | |
| } | |
| # MacOS: brew install entr |
This file contains hidden or 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
| /*global jQuery */ | |
| /*jslint browser: true */ | |
| (function (win, $) { | |
| 'use strict'; | |
| // helpers | |
| var Util, Globals; |
This file contains hidden or 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
| radio() { | |
| local radio | |
| local station | |
| local playlist | |
| if test $# -eq 2; then | |
| radio="$1" | |
| station="$2" | |
| elif test $# -eq 0; then | |
| radio=soma |
This file contains hidden or 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
| my-proxy() { | |
| sudo networksetup -setsocksfirewallproxystate Wi-Fi on | |
| sudo networksetup -setsocksfirewallproxy Wi-Fi localhost 8001 | |
| ssh cbecker -C -N -D 8001 # change your ssh info here | |
| sudo networksetup -setsocksfirewallproxystate Wi-Fi off | |
| } |
This file contains hidden or 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
| xbox-convert() { | |
| if test $# -eq 1; then | |
| local extension=$(echo "$1" | egrep -o '\.[^\.]+$') | |
| local file=$(echo "$1" | sed -e "s/"$extension"$//") | |
| if test -f "$file.srt" && test -f "$1"; then | |
| ffmpeg -sub_charenc "ISO-8859-1" -i "$file.srt" "$file.ass" | |
| ffmpeg -i "$1" -vf ass="$file.ass" -vcodec libx264 -acodec ac3 -ab 160k "$file.mp4" | |
| rm "$file.ass" | |
| else | |
| echo ".str file and video file should have the same name" |
This file contains hidden or 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
| # RESIZE AND OPTIMIZE (based in height) | |
| HEIGHT=500 | |
| mkdir -p result | |
| for f in *.jpg; do | |
| convert "$f" -resize "x${HEIGHT}" -strip -quality 90% "result/$f" | |
| done | |
| # THUMB | |
| WIDTH=200 | |
| HEIGHT=225 |
This file contains hidden or 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
| function type(e) { | |
| var t = Object.prototype.toString.call(e), | |
| r = /\[object (\w+)\]/i.exec(t); | |
| return r && r[1].toLowerCase(); | |
| } | |
| [1,"2", true, null, [], {}, function() {}, undefined].forEach(function(e){ | |
| console.log(type(e)) | |
| }); |
NewerOlder