Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sblask
sblask / national_geographic_photo_contest_2012_wallpaper_download.sh
Last active December 25, 2015 13:28
Download all available wallpapers from National Geographic's photo contest 2012
#!/bin/bash
root=http://ngm.nationalgeographic.com
path=ngm/photo-contest/2012/entries/wallpaper
type=(nature places people)
for kind in "${type[@]}"
do
for week in {1..13}
do
@sblask
sblask / spark_read_avro_example
Last active December 26, 2015 21:09
How to read Avro files using Spark.
import org.apache.avro.generic.GenericRecord
import org.apache.avro.mapred.AvroKey
import org.apache.avro.mapreduce.AvroKeyInputFormat
import org.apache.hadoop.io.NullWritable
import org.apache.spark.SparkContext
private def readAvro(sparkContext: SparkContext, path: String) = {
sparkContext.newAPIHadoopFile[
AvroKey[GenericRecord],
NullWritable,
@sblask
sblask / .pylintrc
Created November 4, 2013 13:59
PyLint configuration file, initially generated with `pylint --generate-rcfile ` and then edited. See http://docs.pylint.org/features.html for disabled messages
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.
@sblask
sblask / redshift.conf
Last active December 28, 2015 03:19
Redshift Settings
redshift -l 59.29:18.01 -t 5800:4500
@sblask
sblask / logging_configuration.py
Last active August 31, 2019 14:52
Python logging configuration
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)5s - %(name)s - %(message)s',
filename=os.path.join(os.path.sep, 'path'),
)
def get_log_handler():
log_format = '%(asctime)s - %(levelname)5s - %(name)s - %(message)s'
log_filename = os.path.join(os.path.sep, 'path')
log_formatter = logging.Formatter(log_format)
@sblask
sblask / ls
Created November 19, 2013 13:46
ls with list, human readable sizes, hidden files and sorting
ls -lhac
@sblask
sblask / national_geographic_wallpaper_archive_download.sh
Created November 26, 2013 01:01
Download national geographic wallpaper archive
#!/bin/bash
root=http://ngm.nationalgeographic.com/wallpaper/img/
year_number=07
months_letters=(jan feb march april may june july aug sept oct nov dec)
for month in {1..12}
do
month_letters=${months_letters[month - 1]}
for index in {1..20}
@sblask
sblask / national_geographic_wallpaper_download.sh
Last active December 29, 2015 09:39
Download all wallpapers from national geographic
#!/bin/bash
root=http://ngm.nationalgeographic.com
months=(january february march april may june july august september october november december)
download() {
year=$1
from=$2
to=$3
for month in $(seq $from $to)
@sblask
sblask / .gtkrc-2.0
Created December 28, 2013 01:18
Remove pixel to the right of scroll bar to simplify scrolling using mouse pointer. (Xfce/Gtk)
style "scrollbar"
{
GtkScrollbar::trough-border = 0
}
class "Gtk*Scrollbar" style "scrollbar"
sudo sh -c "ulimit -n 65535 && exec su $LOGNAME"