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
#!/bin/bash | |
# | |
# basic iptables starter script that only allow incoming SSH and ping | |
# | |
# default actions | |
iptables -P INPUT DROP | |
iptables -P FORWARD DROP | |
iptables -P OUTPUT ACCEPT |
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
#!/bin/bash | |
# | |
# Usage: | |
# ./pi.sh backup /dev/sdb | |
# ./pi.sh restore /dev/sdb | |
# | |
# Files created and used during backup and restore: | |
# mbr.img sfdisk.dump partition[12].parted | |
# | |
# For raspbian images, use minimum 8GB microsd card |
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
// drag and drop multiple files | |
Cypress.Commands.add("upload_files", (selector, fileUrlArray, type = "") => { | |
const files = []; | |
fileUrlArray.forEach((fileUrl) => { | |
cy.fixture(fileUrl, "base64") | |
.then(Cypress.Blob.base64StringToBlob) | |
.then((blob) => { | |
const nameSegments = fileUrl.split("/"); | |
const name = nameSegments[nameSegments.length - 1]; | |
files.push(new File([blob], name, { type })); |
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
{ | |
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1');", |
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 | |
/** | |
* Calculate number of weekdays between two dates. | |
* | |
* @param string $from Start date, in format "YYYY-MM-DD" | |
* @param string $to End datem in format "YYYY-MM-DD" | |
* @return int|null Number of weekdays between $from and $to. NULL if either $from or $to is NULL. | |
*/ | |
static function date_diff_weekdays($from, $to) { |
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
#!/usr/bin/env python | |
""" | |
Wrapper script to compress multiple hard linked files. | |
Hard links are preserved after compression. | |
It does this by removing all but one of the links, compressing the data under the remaining name, | |
then respectively linking again to the newly compressed file (but with added suffix e.g ".bz2") |
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
#!/bin/bash | |
# | |
# Download latest Firefox 32-bit installer for Windows | |
# | |
url=$(wget -S --max-redirect 0 \ | |
"https://download.mozilla.org/?product=firefox-latest&os=win" 2>&1 \ | |
| grep "^Location" | cut -d ' ' -f 2) | |
if [ $# -ne 0 ]; then { echo $url; return 0; }; fi | |
wget "$url" -O "${url##*/}" |
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
#!/bin/bash | |
# Download latest Sublime Text 3 installer | |
url=$(curl -s "https://www.sublimetext.com/3" \ | |
| grep "dl_linux.*tarball" \ | |
| cut -d '"' -f 6) | |
curl "$url" -o ${url##*/} | |
# Example of installation: | |
# | |
# tar -jxvf sublime_text_3_build_3126_x64.tar.bz2 -C ~ |
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
#!/bin/bash | |
# | |
# Download latest Adobe Reader 11 update installer | |
# | |
page2=$(curl -s "http://supportdownloads.adobe.com/product.jsp?product=10&platform=Windows" \ | |
| grep "Adobe Reader 11.*update - All" \ | |
| head -n 1 \ | |
| cut -d '"' -f 2) | |
echo "> $page2" |
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
#!/bin/bash | |
# | |
# Download latest stable LibreOffice for Windows x86 | |
# | |
urla=$(curl -s "https://www.libreoffice.org/download/download/" \ | |
| grep "option.*type=win-x86\&" | head -n 2 | cut -d '"' -f 2 | tail -n 1) | |
urlb=$(curl -s "$urla" | grep "\.msi" | grep -v "torrent" | tail -n 1 | cut -d '"' -f 6) |