Skip to content

Instantly share code, notes, and snippets.

//
// Computed Property Names //
const foo = {name: 'tom', age: 30, nervous: false}
const bar = {name: 'tim', age: 30, nervous: false}
const baz = {name: 'loo', age: 30, nervous: true}
// BAD:
console.log(foo)
console.log(bar)
console.log(baz)

git add.
git commit -m "commit info"
git push
GH_TOKEN=token electron-builder build -w -p onTagOrDraft

@wwex
wwex / SQL db connection and querying
Created July 24, 2018 11:32
PyMemos - SQL queries #SQL #python
import pyodbc
import pandas as pd
SQL_CONFIG = r"DRIVER={SQL Server}; SERVER=adres\serwera; DATABASE=nazwa_bazy; UID=user_id; PWD=password"
def connect():
try:
conn = pyodbc.connect(
SQL_CONFIG,
@wwex
wwex / zbiór_zasad
Created June 13, 2018 09:06
[ZARZĄDZANIE - Zasady dobrej organizacji] #zasady #organizacja
Decyzja to krok na przód. Ustawiaj zawsze domyślną decyzje tak, żeby proces mógł isć dalej.
Długie LOP nie są realizowane - skracaj je lub dziel na mniejsze.
Spotkania są toksyczne - unikajmy ich i szkolmy jak je przeprowadzać.
Multitasking to zło, wymagajmy skupienia.
Powody do rezygnacji - czy Twoja praca jest wartościowa z perspektywy klienta.
Rozwiązuj problemy drogą eliminacji.
Na początku ignoruj szczegóły - wyznacz 1 krok (mały i konkretny, który wiesz jak zrealizować)
Zawsze zaczynaj od epicentrum - detale nie mają znaczenia bez bazy.
Pareto - róbmy mniej ale niech to przynosi duże efekty.
Utrzymujmy małe zasoby - nie komplikujmy procesów. Wykorzystajmy to co mamy. Zazwyczaj potrzebujemy mniej, niż nam się wydaje.
@wwex
wwex / css_flexbox.css
Created June 11, 2018 11:33
[CSS - FLEX] #css #flex #flexbox
css_flex_container {
display: flex;
/* Direction of the flex container */
flex-direction: row;
flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;
/* Wraps elements if no space */
@wwex
wwex / auto_gui_control.py
Last active June 4, 2018 12:59
[PyMemos - Auto GUI] #python #memo #auto #pyautogui
import pyautogui
print(pyautogui.size())
print(pyautogui.position())
pyautogui.moveTo(10,10, 1.5)
pyautogui.moveRel(200,10, 1.5)
pyautogui.click(400, 200)
pyautogui.doubleClick(400, 200)
pyautogui.middleClick(400, 200)
pyautogui.rightClick(400, 200)
@wwex
wwex / imapclient_mails.py
Last active June 4, 2018 13:02
[PyMemos - Mails] #python #memo #mails
import imapclient
conn = imapclient.IMAPClient('imap.gmail.com', ssl=True)
conn.login('[email protected]', 'password')
conn.select_folder('INBOX', readonly=True)
UIDs = conn.search(['SINCE 20-Aug-2015'])
rawMessage = conn.fetch([47474], ['BODY[]', 'FLAGS']) # 47474 <== UIDs[0]
conn.list_folder()
conn.delete_messages([47474, 47475])
@wwex
wwex / doc_manipulation.py
Last active June 4, 2018 12:59
[PyMemos - Excel, PDF, docs] #python #memo #excel #pdf #doc
import docx
d = docx.Document('demo.docx')
p = d.paragraphs[1]
print(p.text)
print(p.runs[1].bold)
print(p.runs[3].italic)
p.runs[3].underline = True
p.runs[3].text = 'italic and underlined'
p.style = "Title"
@wwex
wwex / beautiful_soup4.py
Last active June 4, 2018 13:01
[PyMemos - WEB Scratching] #python #memo #web #requests
import bs4
res = requests.get('https://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593275994')
res = requests.get('https://www.google.com')
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')
elems = soup.select('#gbw > div > div > div.gb_oe.gb_R.gb_Lg.gb_Bg > div:nth-child(2) > a')
# print(elems[0].text.strip())
print(elems)
@wwex
wwex / logging_to_file.py
Last active June 4, 2018 13:01
[PyMemos - Exception, traceback, logs] #python #memo #exception #traceback #log
import logging
logging.basicConfig(filename='myProgLog.txt', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
# logging.disable(logging.CRITICAL)
logging.debug('Start of program')
def factorial(n):
logging.debug('Start of factorial(%s)' %(n))
total = 1
if not ((n == 0) or (n == 1)):
for i in range(1, n+1):