2019-03-19
Python - Transpose a list using zip, yet transform the result to a list of lists, not a list of tuples
map(list, zip(*list_to_transpose))
2019-03-16
Python - Distinct list, preserving original elements order
from collections import OrderedDict
from itertools import izip, repeat
original_list = ['a', 'b', 'b', 'c']
unique_list = list(OrderedDict(izip(original_list, repeat(None))))
print unique_list
from itertools import izip, repeat
original_list = ['a', 'b', 'b', 'c']
unique_list = list(OrderedDict(izip(original_list, repeat(None))))
print unique_list
Credit to: https://stackoverflow.com/questions/479897/how-to-remove-duplicates-from-python-list-and-keep-order
2019-03-12
Meteor - Determine the version of your meteor instance/project
Navigate to your project root folder using Terminal.
$ cat .meteor/release
METEOR@1.8.0.2
2019-03-10
Python - Get the path of the grandparent directory of the current script
from os import path
print path.dirname(
path.dirname(
path.abspath(__file__)
)
)
Python - Get the path of the directory that holds the current script (not including the current script file name)
from os import path
print path.dirname(
path.abspath(__file__)
)
Python - Retrieve the absolute path of the current script, including its name
from os import path
print path.abspath(__file__)
2019-03-08
Python - Inserting a column to an existing list of lists (fixed value or numerical count/index)
# 1. Original matrixmatrix = [ [1, 'a', 'the letter a'] , [2, 'b', 'the letter b'] ] # 2. Inserting the same fixed valuematrix = [ x + ['new fixed value'] for x in matrix ] # 3. Insert a consecutive numeric valuematrix = [ pair[1] + [pair[0]] for pair in enumerate(matrix) ]
Python - Flatten list of lists using list comprehension
flat = [
y
for x in list_of_lists
for y in x
]
Credits: https://coderwall.com/p/rcmaea/flatten-a-list-of-lists-in-one-line-in-python
y
for x in list_of_lists
for y in x
]
Credits: https://coderwall.com/p/rcmaea/flatten-a-list-of-lists-in-one-line-in-python
2019-03-01
Windows - How to delete all browser caches
@echo off
taskkill /f /im iexplore.exe
erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"
erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"
erase "%ALLUSERSPROFILE%\TEMP\*.*" /f /s /q
for /D %%i in ("%ALLUSERSPROFILE%\TEMP\*") do RD /S /Q "%%i"
erase "%SystemRoot%\TEMP\*.*" /f /s /q
for /D %%i in ("%SystemRoot%\TEMP\*") do RD /S /Q "%%i"
@rem Clear IE cache - (Deletes Temporary Internet Files Only)
start "" "C:\Windows\System32\rundll32.exe" InetCpl.cpl,ClearMyTracksByProcess 255
erase "%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*") do RD /S /Q "%%i"
set DataDir=C:\Windows\Downloaded Program Files
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
taskkill /f /im iexplore.exe
erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"
erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"
erase "%ALLUSERSPROFILE%\TEMP\*.*" /f /s /q
for /D %%i in ("%ALLUSERSPROFILE%\TEMP\*") do RD /S /Q "%%i"
erase "%SystemRoot%\TEMP\*.*" /f /s /q
for /D %%i in ("%SystemRoot%\TEMP\*") do RD /S /Q "%%i"
@rem Clear IE cache - (Deletes Temporary Internet Files Only)
start "" "C:\Windows\System32\rundll32.exe" InetCpl.cpl,ClearMyTracksByProcess 255
erase "%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*") do RD /S /Q "%%i"
set DataDir=C:\Windows\Downloaded Program Files
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
Subscribe to:
Posts (Atom)