Skip to content

Instantly share code, notes, and snippets.

@safly
safly / msys_hetzner-etc_network_interfaces
Created August 10, 2018 12:00 — forked from jpawlowski/msys_hetzner-etc_network_interfaces
Debian network configuration for Proxmox VE server running on a Hetzner host
# /etc/network/interfaces
#
auto lo
iface lo inet loopback
# device: eth0
iface eth0 inet manual
# IPv4 bridge
# (connect ONLY your firewall/router KVM instance here, this is the WAN device!)
@safly
safly / download_glue_data.py
Created February 27, 2019 12:43 — forked from W4ngatang/download_glue_data.py
Script for downloading data of the GLUE benchmark (gluebenchmark.com)
''' Script for downloading all GLUE data.
Note: for legal reasons, we are unable to host MRPC.
You can either use the version hosted by the SentEval team, which is already tokenized,
or you can download the original data from (https://download.microsoft.com/download/D/4/6/D46FF87A-F6B9-4252-AA8B-3604ED519838/MSRParaphraseCorpus.msi) and extract the data from it manually.
For Windows users, you can run the .msi file. For Mac and Linux users, consider an external library such as 'cabextract' (see below for an example).
You should then rename and place specific files in a folder (see below for an example).
mkdir MRPC
cabextract MSRParaphraseCorpus.msi -d MRPC
@safly
safly / openssl_encrypt_decrypt.php
Created May 20, 2019 05:51 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@safly
safly / run_fio.sh
Created June 29, 2019 05:16 — forked from sennajox/run_fio.sh
A script that runs fio test and genearates a simple result for each jobs
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage:$0 dev output_dir [iodepth]"
echo "example 1: Testing the whole block device. Attention: That will destory the filesystem on the target block device"
echo "./run_fio.sh /dev/sdb fio_test"
echo ""
echo "example 2: Testing a file, but not destory filesystem. Suppose the target device mount on /data"
echo "fallocate -l 1G /data/test.dat"
echo "./run_fio.sh /data/test.dat fio_test"
#!/bin/bash
# save as /root/del_user.sh
USERNAME=$1
if [[ -z "$USERNAME" ]]; then
echo "Please give me a username"
exit 1
fi
echo "This script will"
@safly
safly / astro-portal.php
Created November 4, 2019 12:22 — forked from yymao/astro-portal.php
astro portal: search for arXiv, DOI, ADS bibcode, and first author + year, without typing syntax keywords!
<?php
if(isset($_GET['q'])){
$url_base = 'https://ui.adsabs.harvard.edu/#search/q=';
#doi
$re = '/\b10\.\d{4,}(?:\.\d+)*\/(?:(?![\'"&<>])\S)+/';
if (preg_match($re, $_GET['q'], $matches)){
if (isset($_GET['rd'])){
$url = $url_base . 'doi%3A' . urlencode($matches[0]);
}
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@safly
safly / gunzip.conf
Created January 31, 2020 13:26 — forked from ryd994/gunzip.conf
server {
listen unix:/var/run/nginx-gunzip.sock;
location / {
proxy_set_header Accept-Encoding gzip;
proxy_pass http://$host$request_uri;
gunzip on;
access_log off;
}
}
@safly
safly / upgrade-openssh-7.3p1-centos-6.7.sh
Created February 3, 2020 03:15 — forked from faishal/upgrade-openssh-7.3p1-centos-6.7.sh
Upgrade OpenSSH to 7.3p1 in Cent OS 6
#!/bin/bash
# Copyright © 2016 Faishal Saiyed
cd
timestamp=$(date +%s)
if [ ! -f openssh-7.3.zip ]; then wget https://github.com/faishal/openssh-portable/releases/download/cent.os.6.7.openssh.7.3p1/openssh-7.3.zip; fi;
unzip -o openssh-7.3.zip -d openssh-7.3p1
cd openssh-7.3p1/
cp /etc/pam.d/sshd pam-ssh-conf-$timestamp
rpm -U *.rpm
yes | cp pam-ssh-conf-$timestamp /etc/pam.d/sshd