Skip to content

Instantly share code, notes, and snippets.

View luizpestana's full-sized avatar
🎮
Game, Dev and GameDev

Luiz Pestana luizpestana

🎮
Game, Dev and GameDev
View GitHub Profile
@luizpestana
luizpestana / encdec.sh
Last active December 8, 2016 10:56
Encrypt clipboard messages using public key
# 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
@luizpestana
luizpestana / readpdfcollection.cs
Created December 8, 2016 10:59
Read PDF files from collection
// 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 / runonce.cs
Created December 8, 2016 11:00
Run only one process .Net
foreach (Process proc in Process.GetProcesses())
if ((proc.ProcessName == Path.GetFileNameWithoutExtension(Application.ExecutablePath)) && (proc.Id != Process.GetCurrentProcess().Id))
proc.Kill();
@luizpestana
luizpestana / compression.cs
Last active December 8, 2016 11:03
Using compression in .Net
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 / .bashrc
Created December 21, 2017 02:15
Colorful terminal
# ~/.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