Skip to content

Instantly share code, notes, and snippets.

View Wingless-Archangel's full-sized avatar
🏠
Working from home

Wingless-Archangel

🏠
Working from home
  • The Matrix
View GitHub Profile
@Wingless-Archangel
Wingless-Archangel / Vagrantfile
Created May 31, 2020 02:41
Vagrant with windows 10 trial from Microsoft with some analysis tool installation with Chocolatey
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
@Wingless-Archangel
Wingless-Archangel / decrypt.sh
Last active May 14, 2020 03:27
Simple Bash encryption/decryption operation for cron purpose
# set the Default Static Variable
# if already set Environment variable, please comment this section
SRC_PATH=/opt/b # src to read recommend full path
DEST_PATH=/opt/a # encrypted to
# assume that the expect output file format is .txt
# Also, make sure that you import the private key before running the file via
# gpg --import private.key
for FILE in $(ls *.gpg)
@Wingless-Archangel
Wingless-Archangel / gitlab_list.py
Created November 18, 2019 08:40
Retreive repository in Gitlab via API
import json
import requests
URL = 'https://gitlab.com/api/v4/projects'
API_KEY = ''
payload = {'private_token' : API_KEY,'simple' : True}
def main():
''' make the connection to local gitlab '''
conn = requests.get(URL,params=payload)
dict_result = json.loads(conn.text)
@Wingless-Archangel
Wingless-Archangel / tapeequilibrium.py
Created November 6, 2016 16:42
find the least difference between 2 part of the same list
# you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
def solution(A):
# write your code in Python 2.7
# Split list into 2 list
if len(A) == 0:
return 0
if len(A) == 1:
return A[0]
@Wingless-Archangel
Wingless-Archangel / listcomprehension.py
Created November 6, 2016 06:12
one liner python with list
#!/usr/bin/python3
def main():
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
b = [i for i in a if i % 2 == 0]
print(b)
if __name__=='__main__':
@Wingless-Archangel
Wingless-Archangel / palindrome.py
Created November 6, 2016 06:11
find out the string is palindrome or not.
#!/usr/bin/python3
def main():
text = input("Please enter the text to test : ")
if text == text[::-1]:
print("This text is palindrome.")
else:
print("This text is not palindrome.")
@Wingless-Archangel
Wingless-Archangel / overlap.py
Created November 5, 2016 07:41
return the list of element that exists in 2 list
#!/usr/bin/python3
def main():
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
ans = list(set([num for num in a if num in a and num in b]))
print(ans)
if __name__ =='__main__':
main()
@Wingless-Archangel
Wingless-Archangel / divisor.py
Created November 5, 2016 07:21
get the result of the element that could be divided by
#!/usr/bin/python3
def main():
ref = input("Please enter the divisor : ")
print([ans for ans in range(2,10) if ans % ref == 0])
if __name__ == '__main__':
main()
@Wingless-Archangel
Wingless-Archangel / listless.py
Created November 5, 2016 06:34
return the element which less than the input number
#!/usr/bin/python3
# Take a list, say for example this one:
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# and write a program that prints out all the elements of the list that are less than 5.
# Extras:
# 1. Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out this new list.
# 2. Write this in one line of Python.
@Wingless-Archangel
Wingless-Archangel / oddeven.py
Created November 5, 2016 03:03
determine the odd and even number from input
#!/usr/bin/python3
import sys
def main():
num = input("please enter the number : ")
if num.isnumeric() != True:
print("Please enter the number")
sys.exit(1)
if num % 2 == 0:
print("this number is even")