Skip to content

Instantly share code, notes, and snippets.

View pbalduino's full-sized avatar

Plínio Balduino pbalduino

View GitHub Profile
@pbalduino
pbalduino / obfuscated.clj
Last active December 17, 2015 12:59
Obfuscation example
; first I received this, and its result is 5. why?
((fn [[?<& %*+ $*|]](?<& %*+ $*|))({['*$] [+ (+ (*) (*)) (* 3 (*))]} ['*$]))
; so I formatted the code
((fn [[?<& %*+ $*|]]
(?<& %*+ $*|))
({['*$] [+ (+ (*) (*)) (* 3 (*))]} ['*$]))
; ?<& is the first parameter, %*+ is the second and $*| is the last. let's rename to x, y and z
;;; base64.clj: Experimental Base-64 encoding and (later) decoding
;; by Stuart Sierra, http://stuartsierra.com/
;; August 19, 2009
;; Copyright (c) Stuart Sierra, 2009. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this
;; distribution. By using this software in any fashion, you are
#!/bin/bash
# SCRIPT: method1.sh
# PURPOSE: Process a file line by line with PIPED while-read loop.
FILENAME=$1
count=0
cat $FILENAME | while read LINE
do
ufw deny from $LINE
done
@pbalduino
pbalduino / def.clj
Last active December 18, 2015 06:08
Qual o valor mostrado?
; Qual o valor mostrado na tela? 10, 20, 30 ou nem compila?
(def m 10)
(defn foo [m]
(def m 20)
(println m))
(foo 30)
digraph repl {
LER -> EXECUTAR -> IMPRIMIR -> LER
}
@pbalduino
pbalduino / comment.clj
Created July 8, 2013 15:45
Comentários no Clojure
; uma linha
; outra linha
(comment comentário que ocupa
várias linhas.
Eu particularmente acho feio)
; pra caraleo
; então prefiro
; contiunar usando
; assim
import java.sql.*;
public class SqliteSample {
private Connection conn;
private boolean inserting;
public void openDB() throws ClassNotFoundException {
Class.forName("org.sqlite.JDBC");
try {
(ns logic.core
(use [clojure.math.combinatorics]))
(defn solve-logic-puzzle-1 []
"http://rachacuca.com.br/logica/problemas/1/"
(let [people [:espanhol :alemao :italiano]]
(first
(for [[casa1 casa2 casa3] (permutations people) ; casas
[azul vermelha preta] (permutations people) ; cores
; O Espanhol mora diretamente à direita do homem que mora na casa vermelha.
@pbalduino
pbalduino / gist:7268251
Last active December 27, 2015 04:39
Argument verification with Clojure
(defn -main[& args]
(if-let [_ args]
(println "with args")
(println "without args")))
; $ lein run
; without args
; $ lein run meh
; with args
(defn border [x]
(cond (= (meta x) nil) "nao autorizado"
(= ((meta x) :type) "valinor") x
:default "lixo"))
;Associar um meta a sua função de validação
;teste
(def x (with-meta [1 2 3 4] {:type "valinor"}))