Skip to content

Instantly share code, notes, and snippets.

View ihercowitz's full-sized avatar

Igor Hercowitz ihercowitz

View GitHub Profile
@ihercowitz
ihercowitz / pdfreducer.sh
Created August 6, 2021 15:48
Reduce PDF Size
LEVEL=1.3&& RES=92 && gs -sDEVICE=pdfwrite -dCompatibilityLevel=$LEVEL -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -dColorImageDownsampleType=/Bicubic \ -dColorImageResolution=$RES \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=$RES \ -dMonoImageDownsampleType=/Subsample \ -dMonoImageResolution=$RES \ -sOutputFile=output.pdf input.pdf
@ihercowitz
ihercowitz / gist:83fff0d1e6a96ee991723d2b7fc4ca21
Created November 16, 2020 14:00
Some Tips to do a better code or points to have in mind when do a cross code-review
Some Tips to do a better code or points to have in mind when do a cross code-review:
- Classes and methods small -> Classes should represent simple entities. Methods should have one job. This is crucial for testing, refactoring, understanding, and maintaining.
- Make class fields private, and provide getters when necessary -> This is necessary to encapsulate the logic in a class, so callers are not dependent on the class implementation.
- Immutable classes -> Usage of setters are not a good practice. Using this on the classes, will let the data mutable, and the results can be catastrophic. Also, use final on variables (this will make them immutable).
- Avoid large blocks of code -> Use whitespace to separate tiny, logical chunks of code. (Do not be afraid of whitespace. It is your friend.) Use inline documentation to describe unclear bits of code, but better yet, restructure your code and rename methods/variables until the code is clear.
@ihercowitz
ihercowitz / std-militar.clj
Last active July 22, 2016 15:51
Convert Standard Time (AM/PM) to Militar Time (24h)
(defmulti std-to-militar (fn [hour time-info] (keyword time-info)))
(defmethod std-to-militar :AM [hour _]
(format "%02d" (if (= hour 12) 0 hour)))
(defmethod std-to-militar :PM [hour _]
(if (= hour 12) hour (+ hour 12)))
(defn convert-time [hour]
(let [[hour minute seconds time-info] (rest (re-find #"(\d+):(\d+):(\d+)(\w+)" hour))]
@ihercowitz
ihercowitz / core.cljs
Created December 24, 2015 20:08
Feliz natal like a Developer
(ns merrychristmas.core
(:require [reagent.core :as reagent :refer [atom]]))
(defn greetings []
(letfn [(crazy-letters [size] (clojure.string/join " " (take size (repeatedly #(rand-nth (range -20 10))))))]
[:svg#merry {:width "1000px"
:height "900px"}
[:text {:x "600px"
:y "260px"
:font-family "sans-serif"
@ihercowitz
ihercowitz / core.clj
Created April 28, 2015 16:33
A mastermind board game (http://en.m.wikipedia.org/wiki/Mastermind_(board_game)) implementation in clojure...
(ns mastermind.core
(:gen-class))
(defn generate-numbers []
(let [game [1 2 3 4 5 6]]
(->> game shuffle (take 4) vec)))
(defn guess [user answer]
(map #(= %1 %2) user answer))
@ihercowitz
ihercowitz / PBMagnet.py
Last active August 29, 2015 14:19
Script to download series on kickassTorrents, using Aria
# -*- coding: utf-8 -*-
import requests
from lxml.html import fromstring
import os, sys
piratebay = "https://thepiratebay.se/search/{0}/0/99/0"
kickass = "https://kickass.to/usearch/{0}/"
magnet=lambda link, local: os.system('aria2c --conf-path=$HOME/.aria2c.torrent --max-download-limit=1100K --max-upload-limit=15K --listen-port=63654 "' + link + '" -d '+ local +' --seed-time=1')
@ihercowitz
ihercowitz / batchmagnet.py
Created February 28, 2015 01:41
A simple script to batch download series from KickassTorrents
# -*- coding: utf-8 -*-
import requests
from lxml.html import fromstring
import os
kickass = "https://kickass.to/usearch/{0}/"
magnet=lambda link, local: os.system('aria2c --conf-path=$HOME/.aria2c.torrent --max-download-limit=1100K --max-upload-limit=15K --listen-port=63654 "' + link + '" -d '+ local +' --seed-time=1')
localFolder="~/Vídeos/Seriados/Gotham"
;; Bingo Real recriado em Lisp
;; - Roda direto no Emacs -
;;
;; Como rodar:
;; - Abrir o arquivo no Emacs
;; - Alt-x
;; - Digitar eval-current-buffer
;; - Os assuntos serao gerados na area de mensagens apertando Control-F2
(require 'cl)
@ihercowitz
ihercowitz / rainbownize.clj
Created September 18, 2014 19:23
A color festival for your texts. Maybe this could be used on LOG FIles
(defonce color-map (range 255))
(defn rand-color [max]
(nth color-map (rand-int max)))
(defn rainbownize [& text]
(->> (clojure.string/join #" " text)
seq
(map #(str "\033[38;5;" (rand-color 254) "m" % "\033[0m"))
(apply str)))
@ihercowitz
ihercowitz / utils.clj
Created August 22, 2014 01:00
clojure function call function runtime
(ns test-macro.utils)
(defn test-me []
(str "Test me"))
(defn test-you []
(str "Test you"))
(defn run-me [fn]
(eval (read-string (str "(test-macro.utils/test-" fn ")"))))