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/env python | |
# | |
# USAGE | |
# $ python ad_utils.py "My Group Name" | |
# | |
# Author: | |
# Trinh Nguyen | |
# dangtrinhnt@gmail.com | |
# www.dangtrinh.com |
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 | |
# example csv file, mycsv.csv: | |
# | |
# path,some_field | |
# somepath,some_value | |
# anotherpath,another_value | |
# ... | |
# | |
# run the following command: | |
# ./get_blogid_from_url.sh mycsv.csv myblog.com /wordpress/path > result.csv |
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 | |
for blog_path in $(wp site list --field=path) | |
do | |
path_wo_slashes="${blog_path////""}" | |
url="http://your.blog.address/$path_wo_slashes" | |
# status = approve, hold, trash, spam | |
tmp_ids=$(wp comment list --status=hold --format=ids --url=$url) | |
# clean the string | |
pending_ids="$(echo -e "${tmp_ids}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" |
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 python | |
""" | |
File: autorotate.py | |
Origial Author: Damien Riquet <d.riquet@gmail.com> | |
Current Maintainer: Trinh Nguyen <dangtrinhnt[at]gmail[dot]com> | |
Description: This script provides an auto-rotate feature of pictures | |
USAGE: autorotate.py [-h] [--recursive] directory [directory ...] | |
positional arguments: |
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 rowToDict(sheet, rownumber) { | |
var columns = sheet.getRange(1,1,1, sheet.getMaxColumns()).getValues()[0]; | |
var data = sheet.getDataRange().getValues()[rownumber-1]; | |
var dict_data = {}; | |
for (var keys in columns) { | |
var key = columns[keys]; | |
dict_data[key] = data[keys]; | |
} | |
return dict_data; | |
} |
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
autoload -U compinit promptinit colors | |
compinit | |
promptinit | |
colors | |
# set completion style | |
export ZLS_COLORS=$LS_COLORS | |
zstyle ':completion:*' menu select | |
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==34=34}:${(s.:.)LS_COLORS}")'; |
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
// dictionary of columns (list) | |
// thedict = {'<col_header0>': ['<row0>','<row1>',...], '<col_header1>': ['<row0', '<row1>',...]...} | |
function sheet_to_dict(spreadsheetid, sheetname) { | |
var result_dict = {}; | |
var dataspreadsheet = SpreadsheetApp.openById(spreadsheetid); | |
var sheet = dataspreadsheet.getSheetByName(sheetname); | |
var cols = sheet.getLastColumn(); | |
var rows = sheet.getLastRow(); | |
var data = sheet.getDataRange().getValues(); |
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
import openpyxl | |
import string | |
def index_to_col(index): | |
return string.uppercase[index] | |
def excel_to_dict(excel_path, headers=[]): | |
wb = openpyxl.load_workbook(excel_path) | |
sheet = wb.get_sheet_by_name('Sheet1') |
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/php | |
<?php | |
// USAGE: | |
// $ php update_moodle_photo.php <user-id-number> | |
// | |
// to be able to run this file as command line script | |
define('CLI_SCRIPT', true); | |
// include config.php from your moodle's docroot | |
require_once('/var/www/moodle/config.php'); |
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
FROM mcr.microsoft.com/windows/servercore:ltsc2019 | |
# everything will be installed inside this directory inside the container | |
WORKDIR "C:/ProgramData" | |
# install chocolately package manager | |
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" -Y | |
RUN choco install openjdk8 -Y | |
RUN refreshenv |
NewerOlder