Skip to content

Instantly share code, notes, and snippets.

@luizpestana
luizpestana / .bashrc
Created Dec 21, 2017
Colorful terminal
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@luizpestana
luizpestana / compression.cs
Last active Dec 8, 2016
Using compression in .Net
View compression.cs
using System.IO;
using System.IO.Compression;
//---------------
string stringNormal = "seutexto";
byte[] byteArr = Encoding.Unicode.GetBytes(stringNormal);
// Você pode trocar o MemoryStream pelo FileStream para salvar em arquivo.
@luizpestana
luizpestana / runonce.cs
Created Dec 8, 2016
Run only one process .Net
View runonce.cs
foreach (Process proc in Process.GetProcesses())
if ((proc.ProcessName == Path.GetFileNameWithoutExtension(Application.ExecutablePath)) && (proc.Id != Process.GetCurrentProcess().Id))
proc.Kill();
@luizpestana
luizpestana / readpdfcollection.cs
Created Dec 8, 2016
Read PDF files from collection
View readpdfcollection.cs
// Using Lib iTextSharp: http://sourceforge.net/projects/itextsharp/
PdfReader reader = new PdfReader("Portifolio.pdf"); // Seu arquivo collection
for (int x = 0; x < reader.XrefSize; x++) // Loop em todos os objetos
{
PdfObject obj = reader.GetPdfObject(x);
if ((obj != null) && (obj.IsDictionary()) && (obj.ToString().EndsWith("/Filespec")))
{
PdfDictionary filespec = (PdfDictionary)obj;
PdfDictionary refs = filespec.GetAsDict(PdfName.EF);
@luizpestana
luizpestana / encdec.sh
Last active Dec 8, 2016
Encrypt clipboard messages using public key
View encdec.sh
# include this in your ~/.bashrc
# enc usage:
# 1) put the public keys (pem files) in ~/.keylist/recipient_name.pem
# 2) copy the text you want to encrypt
# 3) go to terminal and type enc recipient_name to encrypt your clipboard
# dec usage:
# 1) copy the encrypted message
# 2) go to terminal and type dec
You can’t perform that action at this time.