# How to shrink / compress pdf files?

Question: How to shrink / compress pdf files?

There are many different ways to compress / shrink pdf files. Some of them are;

1. Programmatically
1. Ghostscript – script sourceA simple wrapper around Ghostscript to shrink PDFs (as in reduce filesize) under Linux. Inspired by some code I found in an OpenOffice Python script (I think). The script feeds a PDF through Ghostscript, which performs lossy recompression by such methods as downsampling the images to 72dpi. The result should be (but not always is) a much smaller file.

shrinkpdf.sh

#!/bin/sh

# http://www.alfredklomp.com/programming/shrinkpdf
#
# Copyright (c) 2014, Alfred Klomp
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

shrink ()
{
gs					\
-q -dNOPAUSE -dBATCH -dSAFER		\
-sDEVICE=pdfwrite			\
-dCompatibilityLevel=1.3		\
-dPDFSETTINGS=/screen			\
-dEmbedAllFonts=true			\
-dSubsetFonts=true			\
-dAutoRotatePages=/None		\
-dColorImageDownsampleType=/Bicubic	\
-dColorImageResolution=$3 \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=$3		\
-dMonoImageDownsampleType=/Bicubic	\
-dMonoImageResolution=$3 \ -sOutputFile="$2"			\
"$1" } check_smaller () { # If$1 and $2 are regular files, we can compare file sizes to # see if we succeeded in shrinking. If not, we copy$1 over $2: if [ ! -f "$1" -o ! -f "$2" ]; then return 0; fi ISIZE="$(echo $(wc -c "$1") | cut -f1 -d\ )"
OSIZE="$(echo$(wc -c "$2") | cut -f1 -d\ )" if [ "$ISIZE" -lt "$OSIZE" ]; then echo "Input smaller than output, doing straight copy" >&2 cp "$1" "$2" fi } usage () { echo "Reduces PDF filesize by lossy recompressing with Ghostscript." echo "Not guaranteed to succeed, but usually works." echo " Usage:$1 infile [outfile] [resolution_in_dpi]"
}

IFILE="$1" # Need an input file: if [ -z "$IFILE" ]; then
usage "$0" exit 1 fi # Output filename defaults to "-" (stdout) unless given: if [ ! -z "$2" ]; then
OFILE="$2" else OFILE="-" fi # Output resolution defaults to 72 unless given: if [ ! -z "$3" ]; then
res="$3" else res="72" fi shrink "$IFILE" "$OFILE" "$res" || exit $? check_smaller "$IFILE" "\$OFILE"


## Usage

Download the script by clicking the filename at the top of the box. Make it executable. If you run it with no arguments, it prints a usage summary. If you run it with a single argument – the name of the pdf to shrink – it writes the result to stdout:

./shrinkpdf.sh in.pdf > out.pdf

You can also provide a second filename for the output:

./shrinkpdf.sh in.pdf out.pdf

And an output resolution in DPI (default is 72 DPI):

./shrinkpdf.sh in.pdf out.pdf 90

If both the input and the output are regular files, the script checks if the output is actually smaller. If not, it writes a message to stderr and copies the input over the output.

Sorry, Windows users; this one is Linux only. A Windows adaptation of this script can be found on this blog. It’s a bit more user-friendly than my barebones version and also supports drag-and-drop.

# How to search in all files (Windows OS)?

Question: How to search in all files in a given directory? (Windows Operating System)

2. Set directory to search
3. Set file types to search from e.g. *.* , *.txt, *.pdf
4. Set search keyword

# How to stop forced automatic update / restart on windows?

Question: How to stop forced automatic update / restart on windows?

1. Temporary Solution – stop windows update service for current session
1. run the following command
2. net stop “windows update”
2. Permanent Solution – stop windows update – auto restart- change group policies
1. Windows +R
2. gpedit.msc
3. Navigate to
1. Computer Configuration >
3. Windows Components >
4. Windows Update
1. enable “No auto-restart for scheduled Automatic Updates installations”.

# How to watch youtube faster?

Question: How to watch youtube faster?

Playback speed can be set upto 2x in youtube. More than this requires following steps;

1. Open console – (chrome browser  – press Ctrl + Shift + I )
2. vid = document.getElementsByClassName(“video-stream html5-main-video”)[0];
3. vid.playbackRate = ..desired speed… ;
• vid.playbackRate = 3.0;

if you want to use an extension, Video Speed Controller chrome extension works well. press S for playing slower and D for playing faster.

# Must Read Books For Entrepreneurs

Question: What are the must read books for entrepreneurs?

1. The Fred Factor: How passion in your work and life can turn the ordinary into the extraordinary
• postman called Fred fills turns his ordinary job into extraordinary
• amazon
2. Go Giver
• changing the mindset to be a giver, to accomplish your goals you have to give others. eventually in turn, you will get helps to achieve your goals
• amazon
3. Trump, the art of the deal
• teach how to go beyond your own bubble, go big and break your barriers. how to surround yourself with ambitious people to go change the world. how to go out of your comfort zone. getting the confidence you need to accomplish things that noone around you ever tried before.
• ~400 pages
• amazon
4. Think and Grow Rich
• if you believe in yourself, whatever you imageine is possible to achieve
• ~200 pages
• amazon
5. Keep any promise
• author himself suffers family and health issues due to overwork. he shares the steps he followed to balance his life. compromised with stories of people , how they changed their life and exercises that readers can do to change/balance their life and business. exercises that are suggested are really worth reading.
• ~200 pages
• amazon
• stories of different famous entrepreneurs. each story is about ~5 pages long. great motivational boost. could be a great reading as a part of morning routine.
• 400 pages
• amazon
7. The 4 hour workweek
• productivity book. teaching how to automate, how to deligate, how to eliminate, how to outsource, how to apply 80/20 rule to your business. how to be more efficient, get more things done in shorter time and live the life of your dream. challenges the user to think differently, way outside of the box. shows different ways to accomplish your goals that you would have never thought it would be possible. makes you think creatively.
• ~400 pages
• amazon
8. Three kingdomsfiction book
1. leadership, motivating people, honestly, trust, loyalty. three kingdom that tries to control China. One is evil that cheats etc. the other one is honest etc. these two constantly fight. gives ideas about strategy, teamwork etc.
2. ~550 pages
3. amazon

# Big data vs Smart data?

Question: What is big data and what is smart data?

Big data often deals with what are known as the five Vs: volume, velocity, veracity, variety, and value. And, when any one of those Vs of your data begin to overwhelm your attempts to control it, you have a big data problem.

“The smart data is the subset of that data that will actually apply to your problem—that can be used intelligently in a way that takes you towards a solution,”

# Base 4 – Dna Computing vs Quantum Computing?

Question: Base 4 – Dna Computer vs Quantum Computer comparison?

Base 4 computing is classical computing, slightly more efficient for storage of information than a “normal computer”.

To emulate a base-4 computer with n digits, it would take a binary computer with 2-power-n bits.

Quantum computing is very different, capable of implementing much more efficient algorithms for some problems that are infeasible when using classical computers.  The most celebrated example is Shor’s algorithm which solves integer factorization in polynomial time, when the best classical algorithm takes sub-exponential time.

To emulate a quantum computer with n qubits, it would take a classical computer with about 2-power-n bits.

Not every operation on 2-power-n bits can be done in a quantum computer with n qubits, but quantum computing may be fundamentally more powerful than classical computing.

Resources about base-4 / dna computing / quantum computing / ternary computing

travelling salesman problem with dna computing
dna computer helps travelling salesman
base 4 dna computing – quantum computing
base 4 vs quantum computing
why computers use base 2 instead of base 10?
ternary computer

# What are big-O notation calculation tips?

Question: What are big-O notation calculation tips?

1. Multiplicative constants can be omitted: 14n-square becomes n-square
2. n-power-dominates n-bower-if a > b: for instance, n-square dominates n.
3. Any exponential dominates any polynomial: 3-power-dominates n-power-5
(it even dominates 2-power-n).
4. any polynomial dominates any logarithm: n dominates (logn)-power-3. This also means, for example, that n-square dominates n log n.

common functions ordered by growth rates from smallest to largest are as follows:

function        name
--------        ----
1               constant
lg(N)           logarithm
[lg(N)]²        log-squared
N               linear
N·lg(N)         n-log-n
N³              cubic
2N              exponential
N!              factorial


this is shown also in the following graph (which uses a scale to make material fit):

ref: http://www.cis.gvsu.edu/~mcguire/teaching/225/2014_4fall/lectures/12/

# Structural typing vs duck typing?

Question: Structural typing vs duck typing in programming languages?

Duck typing sample:

def test(o)
log o.getName # Let’s hope this will work
end

Structural typing sample:

def test(f: { def getName(): String }) {
log(f.getName)
}

DUCK TYPING STRUCTURAL TYPING CLASS/INTERFACE/TRAIT(1)
Type safe No Yes Yes
Can be automatically refactored No (2) Yes (3) Yes
Respects “Don’t Repeat Yourself” Yes (4) No (5) Yes (6)

ref: http://beust.com/weblog/2008/02/11/structural-typing-vs-duck-typing/

# What is compound interest?

Question: What is compound interest?