Skip to content

Instantly share code, notes, and snippets.

View sonpython's full-sized avatar
🎯
Focusing

Michael Phan sonpython

🎯
Focusing
View GitHub Profile
@sonpython
sonpython / ftp-server.py
Created December 27, 2023 12:55
Simple FTP server in Micropython
#
# Small ftp server for ESP8266 ans ESP32, Pico W Micropython
#
# Based on the work of chrisgp - Christopher Popp and pfalcon - Paul Sokolovsky
#
# The server accepts passive mode only.
# It runs in foreground and quits, when it receives a quit command
# Start the server with:
#
# import ftp
#!/bin/bash
# auto rename disk base on vendor and serial of the disk
# usage: . ./rdisk.sh /dev/sda
sudo apt-get install smartmontools -y > /dev/null
HOSTNAME=`hostname`
DISK_PATH=$1
DISK_WORK_PATH=$DISK_PATH
#!/usr/bin/env bash
# auto clean and update new chia plots directory
# remove all plot directory in config.yaml
sed -i '/\ \ \-\ \/media\/.*$/d' ~/.chia/mainnet/config/config.yaml
# create tmp anchor - tmpdirectory
sed -i 's/\ \ plot_directories\:/\ \ plot_directories\:\n\ \ \- tmpdirectory/g' ~/.chia/mainnet/config/config.yaml
import shutil
import sys
import glob
import os
# Reorganizing chia plot on disk to free disk
# example python diskweap.py /media/plot1
# will check moving all finish plot from disk6 to 1, 5 to 1, 4 to 1, 3 to 1, 2 to 1 then step to disk 2 => 6 to 2...
mount_path = sys.argv[1]
@sonpython
sonpython / backup_postgresql_and_upload_to_s3
Created August 21, 2020 18:38
auto backup dump_all postgres db and upload to s3, digital ocean space
#!/bin/bash
DATETIME=`date +%y%m%d-%H_%M_%S`
SRC=$1
DST=$2
GIVENNAME=$3
showhelp(){
echo "\n\n############################################"
echo "# bkupscript.sh #"
echo "############################################"
echo "\nThis script will backup files/folders into a single compressed file and will store it in the current folder."
import os
import time
import glob
import re
import socket
import imp
import sys
import traceback
import requests
@sonpython
sonpython / 0x00D15422268E29447c851a684594FD06fEab5F55
Created October 1, 2017 03:36
0x00D15422268E29447c851a684594FD06fEab5F55
0x00D15422268E29447c851a684594FD06fEab5F55
@sonpython
sonpython / Eoddata.py
Last active April 20, 2017 18:36
eoddata.com soap API wrapper
from zeep import Client
WSDL_URL = 'http://ws.eoddata.com/data.asmx?wsdl'
class Eoddata():
'''
usage:
eod = Eoddata(username,password)
result = eod.send_request(action='Membership')
@sonpython
sonpython / GoogleDriveGetSlides.py
Created April 7, 2017 17:54
list and get slide + thumbnail in google drive
from __future__ import print_function
import httplib2
from apiclient import discovery
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseRedirect
from oauth2client.client import flow_from_clientsecrets, OAuth2WebServerFlow
from oauth2client.contrib import xsrfutil
from oauth2client.contrib.django_util.storage import DjangoORMStorage
def share_facebook_fanpage(link,msg,PAGE_ID,OAUTH_ACCESS_TOKEN,apiversion='v2.8'):
BASE_URL = "https://graph.facebook.com/%s" % apiversion
POST_URL = "%s/%s/feed" % (BASE_URL, PAGE_ID)
# force facebook scape the link first to avoid not showing thumb
f = requests.post(BASE_URL, data={
'id': link,
'scrape': True,
'access_token': OAUTH_ACCESS_TOKEN
})