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
from bs4 import BeautifulSoup | |
import requests | |
import datetime | |
import logging | |
import csv | |
def setLogger(): | |
logging.basicConfig(level=logging.INFO, | |
format='%(asctime)s - %(levelname)s - %(message)s', | |
filename='logs_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
Sub tableloop() | |
Dim tbl As ListObject | |
Set tbl = ThisWorkbook.Worksheets("wsname").ListObjects("tblname") | |
Dim i As Integer | |
For i = 1 To tbl.ListRows.Count | |
Dim col1val, col2val As String | |
col1val = Trim(tbl.ListColumns("col1name").DataBodyRange(i, 1).Value) | |
col2val = Trim(tbl.ListColumns("col2name").DataBodyRange(i, 1).Value) | |
'do stuff with column values here | |
Next i |
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 numpy as np | |
import pandas as pd | |
#### creating dataframes, adding and dropping columns | |
df = pd.DataFrame(np.arange(1,10).reshape(3,3),['A','B','C'],['w','x','y']) | |
df.columns = ['W','X','Y'] # change column names | |
df['Z']=df['X']+df['Y'] # new column with values X+Y | |
df['XX']=df.apply(lambda row: row['X']*2, axis=1) # new column with values twice of column X | |
df['YY']=1 # new column of ones |
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
Replace a table using data and structure from another one: | |
DROP TABLE IF EXISTS a | |
CREATE TABLE a LIKE b | |
INSERT INTO a SELECT * FROM b | |
Insert into table with possibility of duplicate: | |
INSERT INTO a(`f1`,`f2`) VALUES ('x','y') ON DUPLICATE KEY UPDATE `f2`='y' | |
or |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Sub genreport() | |
Dim wb As Workbook | |
Set wb = Application.Workbooks.Add | |
Dim tbl As ListObject | |
Set tbl = ThisWorkbook.Worksheets("mainsheet").ListObjects("maintable") | |
Dim i, lastrow As Integer | |
lastrow = 1 | |
For i = 1 To tbl.ListRows.Count | |
Dim val As String | |
val = Trim(tbl.ListColumns("Source").DataBodyRange(i, 1).Value) |
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 | |
for filename in *.xlsm; do | |
cp "$filename" "backup/$(basename "$filename" .xlsm) $(date +'%Y%m%d%H%M%S').xlsm" | |
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
// this is a file that puts together all redigo examples for convenience | |
// (see https://godoc.org/github.com/gomodule/redigo/redis#pkg-examples) | |
// | |
// start by ensuring that redis is running on port 6379 (`redis-server`) | |
// uncomment the main method as needed, and run the script (`go run main.go`) | |
package main | |
import ( | |
"fmt" | |
"github.com/gomodule/redigo/redis" |
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
class TreeNode: | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
def buildTree(arr): | |
nodes = [TreeNode(val) for val in arr] | |
for i in range(len(nodes)): | |
left, right = (i+1)*2-1, (i+1)*2 |
OlderNewer