Skip to content

Instantly share code, notes, and snippets.

View akanik's full-sized avatar

Alexandra Kanik akanik

View GitHub Profile
@akanik
akanik / wav-mp3-ffmpeg
Created April 27, 2017 13:48
WAV to MP3 with ffmpeg
ffmpeg -i CAPITOJINX.wav -f mp3 capitojinx.mp3
@akanik
akanik / QGIS_NULL_to_0
Created June 22, 2017 16:51
Turn layer attribute table values from NULL into 0 for styling
case when "Some_Value" IS NULL then 0 else "Some_Value" end
@akanik
akanik / QGIS_leading_0
Created June 22, 2017 16:54
Add leading zero(s) to FIPS codes in QGIS
#county
right( ('000' || tostring( "myfield" )), 4)
#state
right( ('0' || tostring( "fips" )), 2)
@akanik
akanik / terminal-video-to-gif
Last active January 25, 2023 19:04
video to animated gif
#https://github.com/skepticli/tutorial-screencast-to-gif
#command line
mkdir frames
ffmpeg -i my-screencast.mov -r 3 frames/image.%03d.png
#At this point it might be useful to go into your frames
#directory and delete extra images, most likely frames at
#the start and end of your video/gif
@akanik
akanik / query_run_time
Created July 7, 2017 19:00
How long a process takes
#https://stackoverflow.com/questions/1345827/how-do-i-find-the-time-difference-between-two-datetime-objects-in-python
>>> import datetime
>>> a = datetime.datetime.now()
>>> b = datetime.datetime.now()
>>> c = b - a
datetime.timedelta(0, 8, 562000)
>>> divmod(c.days * 86400 + c.seconds, 60)
(0, 8) # 0 minutes, 8 seconds
@akanik
akanik / new-django-install
Last active July 24, 2017 20:44
Steps to setting up a new django install
#virtual environment
>> cd [project-path]
>> mkvirtualenv -a ./ [-r requirements_file] ENVNAME
#install django in virtualenv
>> pip install Django
#create django project
>> django-admin startproject mysite
@akanik
akanik / pivot-blanks
Created August 7, 2017 19:49
Pivot table blanks, fill them in
=if(isblank(B2),A1,B2)
@akanik
akanik / python-combine-csv
Last active March 7, 2019 03:31
combine csv files into one
import os
data_dir = '/Users/akanik/data/csv/'
file1 = 'whatever-data-1.csv'
file1_path = data_dir + file1
#Make sure your combined file does not live within your data_dir.
#This will cause an endless loop of writing
combined_file = '/Users/akanik/data/whatever-data-ALL.csv'
fout = open(combined_file,'a')
@akanik
akanik / pdf-extract
Created May 30, 2018 20:12
Extract pages from a pdf into another pdf
# https://www.commandlinefu.com/commands/view/9002/extracting-a-range-of-pages-from-a-pdf-using-ghostscript
# commandline
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=14 -dLastPage=17 -sOutputFile=OUTPUT.pdf ORIGINAL.pdf
#https://gist.github.com/oag335/9959241
response_data['real_date'] = pd.to_datetime('1899-12-30') + pd.to_timedelta(response_data['date'],'D')