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 is_prime(n): | |
if n <= 1: | |
return False | |
if n <= 3: | |
return True | |
if n % 2 == 0 or n % 3 == 0: | |
return False | |
i = 5 | |
while i * i <= n: | |
if n % i == 0 or n % (i + 2) == 0: |
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
[alias] | |
l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%ae>%Creset' --abbrev-commit |
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 | |
status_file='./status' | |
status_json_file='./status.json' | |
hosts="cml[4,22]" | |
cmd_hostname="cat /etc/hostname | tr '\n' ','" | |
cmd_uptime_and_avgload="uptime | sed 's/[0-9]*:[0-9]*,//' | sed 's/.*up//' | sed 's/load average://' | tr '\n' ','" | |
cmd_cpuinfo="cat /proc/cpuinfo | grep processor | wc -l | tr '\n' ','" | |
cmd_meminfo="cat /proc/meminfo | egrep '^MemTotal|^MemAvailable|^SwapTotal|^SwapFree|^Cached' | tr 'kB' ' ' | awk -F ':' '{printf(\$2\",\")}'" | |
cmd_lastupdate="date +'%H:%M:%S'" |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import json | |
def getWindowsName(data): | |
d = data['jsons'] | |
a = d.keys() | |
for k in a: | |
print(k, d[k]['title']) |
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 | |
sudo cat /etc/shadow \ | |
| awk -F : -v d=$(expr `date +%s` / 86400) \ | |
'{ | |
if ($8 >= 0) { | |
if ($8 > d || $8 <= 0) printf "%15s %5d %s\n", $1, $8, ""; | |
else printf "%15s %5d %s\n", $1, $8, "Expired"; | |
} | |
}' \ |
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 cex_auth(command, user_id, key, secret, callback) { | |
var uri = "https://cex.io/api/"; | |
var nonce = new Date().getTime(); | |
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_256, nonce.toString()+user_id+key, secret); | |
var stringSignature = signature.map(function(byte) { | |
return ('0' + (byte & 0xFF).toString(16)).slice(-2); | |
}).join('').toUpperCase(); | |
var params = { |
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 cex_auth(command, user_id, key, secret, callback) { | |
var uri = "https://cex.io/api/"; | |
var nonce = new Date().getTime(); | |
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_256, nonce.toString()+user_id+key, secret); | |
var stringSignature = signature.map(function(byte) { | |
return ('0' + (byte & 0xFF).toString(16)).slice(-2); | |
}).join('').toUpperCase(); | |
var params = { |
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
const fs = require('fs'); | |
const request = require('request-promise'); | |
const option = { | |
method: 'POST', | |
uri: 'http://phancer.com/upload?net=iphone_6', | |
formData: { | |
file: { | |
value: fs.createReadStream('image_.jpg'), | |
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/bash | |
function show_gpu_user { | |
pid=$(pstree -sg $1 | grep -Eo 'bash\([0-9]*\)' | head -1 | grep -Eo '[0-9]*'); | |
docker ps -q | xargs docker inspect --format "{{.Name}} {{.State.Pid}}" | grep $pid | awk '{printf "%-24s", $1}'; | |
ps aux | grep $1 | grep -v grep | awk '{ for(i=1;i<=NF;i++) {if ( i >= 11 ) printf $i" "}; printf "\n" }'; | |
} | |
echo " "; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder