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 update(dl_url, force_update=False): | |
""" | |
Attempts to download the update url in order to find if an update is needed. | |
If an update is needed, the current script is backed up and the update is | |
saved in its place. | |
""" | |
import urllib | |
import re | |
from subprocess import call | |
def compare_versions(vA, vB): |
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
package main | |
import ( | |
"fmt" | |
"github.com/spf13/cobra" | |
"github.com/spf13/viper" | |
) | |
func main() { |
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 python3 | |
# get_keypress.py | |
import sys | |
import os | |
def main(): | |
try: | |
print("press ctrl+c to exit") |
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
#include <string.h> | |
#include <iostream> | |
#include "boost/program_options.hpp" | |
#include "boost/filesystem.hpp" | |
#include "boost/any.hpp" | |
namespace po = boost::program_options; | |
inline void PrintUsage(const boost::program_options::options_description desc) { | |
std::cout << "Usage: " << app_name << " [options]" << std::endl; |
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
# zero.zsh-theme | |
# forked from af-magic | |
# https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme | |
# color vars | |
eval sys_color='$FG[240]' | |
eval dirty_color='$FG[214]' | |
eval virt_color='$FG[023]' | |
eval git_color='$FG[064]' | |
eval prompt_color='$FG[032]' |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Golang: App", | |
"type": "go", | |
"request": "launch", | |
"mode": "debug", | |
"program": "${workspaceFolder}", | |
"args": [ |
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
"configurations": [ | |
{ | |
"name": "Python: Server", | |
"type": "python", | |
"request": "launch", | |
"envFile": "${workspaceFolder}/.env", | |
"program": "${workspaceFolder}/server.py" | |
}, | |
{ | |
"name": "Python: run file", |
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 logging | |
import logging.handlers | |
LOG_FILE = 'path/to/logfile' | |
LOG_SIZE = 1024*1024*200 | |
LOG_COUNT = 9 | |
log_file = LOG_FILE | |
dir_path = os.path.dirname(log_file) | |
if os.access(dir_path, os.W_OK): |
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 subprocess | |
import sys | |
import os | |
def output_to_pager(text): | |
try: | |
# args stolen fron git source, see `man less` | |
pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'], | |
stdin=subprocess.PIPE, | |
stdout=sys.stdout) |
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
// run a command using the shell; no need to split args | |
// from https://stackoverflow.com/questions/6182369/exec-a-shell-command-in-go | |
func runcmd(cmd string, shell bool) []byte { | |
if shell { | |
out, err := exec.Command("bash", "-c", cmd).Output() | |
if err != nil { | |
log.Fatal(err) | |
panic("some error found") | |
} | |
return out |
NewerOlder