View formula
=SUM(FILTER(A1:A10, B1:10>=("1/1/2019")+0, B1:B10<("1/1/2020")+0))
View docker_install.sh
sudo dnf install docker
sudo ln -sf /usr/bin/dockerd-current /usr/local/bin/dockerd
sudo groupadd docker
sudo systemctl start docker
View memory.cpp
#include <iostream>
#include <new>
#include <cstdlib>
int main()
{
int i=0;
char* ptr =NULL;
while(i<50){
if ((ptr =(char*)malloc(1048576)) == NULL) {///1MB allocated
std::cout << "Allocation fails at " << i << "MB\n";
View pid_namespace.sh
sudo unshare --fork --pid --mount-proc bash
View queue.go
package queue
import (
"encoding/json"
"errors"
"log"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
View delete_nessus.sh
sudo rm -rf /Library/Nessus
sudo rm /Library/LaunchDaemons/com.tenablesecurity.nessusd.plist
sudo rm /Library/PreferencePanes/Nessus Preferences.prefPane
sudo rm -rf /Applications/Nessus
sudo launchctl remove com.tenablesecurity.nessusd
View trust_proxy.js
// trust proxy, otherwise req.ip will be local ip
app.enable('trust proxy')
View mx_check.js
const dns = require('dns')
function hasMxRecords(domain) {
return new Promise((resolve, reject) => {
dns.resolveMx(domain, (err, addresses) => {
if (err) return reject(err)
resolve(addresses && !!addresses.length)
})
})
}
View sign_send_transaction.js
const Transport = require('@ledgerhq/hw-transport-node-hid').default
const AppEth = require('@ledgerhq/hw-app-eth').default
const Tx = require('ethereumjs-tx')
const Web3 = require('web3')
const web3 = new Web3('https://mainnet.infura.io:443')
async function main() {
const index = 1
const devices = await Transport.list()
if (devices.length === 0) throw 'no device'
View mfa.js
import speakeasy from 'speakeasy'
export function generateSecret() {
return speakeasy.generateSecret({
length: 32,
symbols: false
}).base32
}
export function generateAuthUrl({username, secret}) {