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
/** | |
* Create JPEG image with watermark. | |
* @param string $sourceImage path to source JPEG image | |
* @param string $watermark path to watermark in GIF format | |
* @param string $targetImage path to final JPEG image file | |
* @param int $transparency watermark transparency (0 transparent - 100 solid) | |
* @param int $quality quality of final image (0-100) | |
* @param int offsetX offset of watermark from edge in horizontal direction | |
* @param int $offsetY offset of watermark from edge in vertical direction | |
* @param string $alignX alignment of watermark in horizontal direction (left, middle, right) |
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
/** | |
* Resize image - preserve ratio of width and height. | |
* @param string $sourceImage path to source JPEG image | |
* @param string $targetImage path to final JPEG image file | |
* @param int $maxWidth maximum width of final image (value 0 - width is optional) | |
* @param int $maxHeight maximum height of final image (value 0 - height is optional) | |
* @param int $quality quality of final image (0-100) | |
* @return bool | |
*/ | |
function resizeImage($sourceImage, $targetImage, $maxWidth, $maxHeight, $quality = 80) |
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 | |
cd [backup_folder] | |
today=`date +%Y-%m-%d` | |
filename="mysql/mysql-$today.sql" | |
# Backup all databases | |
# mysqldump -u [username] -p[password] --all-databases > $filename |
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
'****CONFIGURE THE FROM EMAIL ADDRESS AND PASSWORD | |
Const fromEmail = "[email protected]" | |
Const password = "password" | |
'****END OF CONFIGURATION | |
Dim emailObj, emailConfig | |
Set emailObj = CreateObject("CDO.Message") | |
emailObj.From = fromEmail |
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/env ruby | |
require 'optparse' | |
require 'optparse/date' | |
options = {} | |
parser = OptionParser.new do |opts| | |
opts.banner = 'Usage: git_stats.rb [options]' |
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/sh | |
unset GIT_DIR | |
cd /var/www/[PROJECT_DIR] && git pull origin master |
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
task :deploy do | |
command = "jekyll build && \ | |
git push origin master && \ | |
rsync -avz --delete _site/ [SERVER]:/var/www/[PROJECT_DIR]" | |
sh command | |
end |
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
function addData() { | |
var values = fetchStats(); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheets()[0]; | |
sheet.appendRow([currentDateTime(), values[0], values[1]]); | |
} | |
function fetchStats() { | |
var url = 'https://instances.mastodon.xyz/list'; | |
var content = UrlFetchApp.fetch(url).getContentText(); |
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
# Provide getter and setter methods for the given matrix and its | |
# inverse that is cached in a variable. | |
makeCacheMatrix <- function(x = matrix()) { | |
# Variable used for caching | |
inverse <- NULL | |
# Set | |
set <- function(y) { | |
x <<- y |
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
def stopwatch(cycles = 1) | |
cycles = cycles.to_i | |
return if cycles == 0 | |
start = Time.now.to_f | |
cycles.times do | |
yield | |
end |
OlderNewer