Skip to content

Instantly share code, notes, and snippets.

@StuffbyYuki
StuffbyYuki / switch_schema.sql
Created February 22, 2022 03:32
Postgres db choose your schema for sql query use
SHOW search_path;
SET search_path TO your_schema;
@StuffbyYuki
StuffbyYuki / get_by_column_name.sql
Created December 10, 2021 19:26
SQL server - get tables/views based on column names
// change .views to .tables for tables
SELECT
sys.columns.name AS ColumnName,
views.name AS TableName
FROM
sys.columns
JOIN sys.views ON
sys.columns.object_id = views.object_id
WHERE
sys.columns.name = 'YOUR_COLUMN';
@StuffbyYuki
StuffbyYuki / getrefreshes.txt
Created November 9, 2021 20:31
Power Query - Get refreshes of a dataset through PBI REST API
(group as text, dataset as text, token as text) =>
let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/",
[
RelativePath = "/groups/" & group & "/datasets/" & dataset & "/refreshes",
Headers=[Authorization="Bearer " & token]
]
)),
value = Source[value]
@StuffbyYuki
StuffbyYuki / datasetsinaworkspace.txt
Created November 9, 2021 20:30
Power Query - Get datasets in a workspace through PBI REST API
(group as text, token as text) =>
let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/",
[
RelativePath = "/groups/" & group & "/datasets",
Headers=[Authorization="Bearer " & token]
]
)),
value = Source[value]
@StuffbyYuki
StuffbyYuki / npm command - list all global packages
Created July 30, 2021 03:12
npm command - list all global packages
npm ls -g --depth 0
@StuffbyYuki
StuffbyYuki / Setup pyenv with homebrew
Created January 30, 2021 22:00
Setup pyenv with homebrew
# Add these to ~/.bash_profile, adding to ~/.bashrc won't work if you use brew to install pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
@StuffbyYuki
StuffbyYuki / RaspberryPi Setup - Simply Guide
Last active December 6, 2020 07:22
RaspberryPi Setup - Simply Guide
1. Download raspberry pi image on your SD card.
2. Create a ssh file with empty content.
3. Create wpa_supplicant.conf file with the content below:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>
network={
ssid="<Name of your wireless LAN>"
@StuffbyYuki
StuffbyYuki / Python: map(), filter(), reduce() functions
Last active November 26, 2020 17:35
Python: map(), filter(), reduce() functions
# map(), filter(), reduce() apply a function to every element in what you pass in
def add(a):
return a + 10
arr = [1,2,3]
print(map(add, arr)) # returns 11, 12, 13
def gt_two(a):
return a > 2
print(filter(gt_two, arr)) # returns [3]
@StuffbyYuki
StuffbyYuki / Python: with statement --> context manager
Last active November 26, 2020 17:37
Python: with statement --> context manager
# This trick is introduced in the book called Python Tricks
# When you do this
with open('hello.txt', 'w') as f:
f.write('hello, world!')
# You're essentially doing this
f = open('hello.txt', 'w')
try:
f.write('hello, world')
finally:
@StuffbyYuki
StuffbyYuki / Python: Add comma at the end of your list or dict
Last active November 26, 2020 17:38
Python: Add comma at the end of your list or dict
# Python accepts a comma at the end of your list/dict
# This is helpful when you define a list/dict vertically, helps you not forget to add a comma when adding a value
arr =[1,
2,
3,]
d = {1: 'a',
2: 'b',
3: 'c',}