Skip to content

Instantly share code, notes, and snippets.

@erickzanardo
erickzanardo / angular-noconflict.js
Last active September 29, 2015 18:28
Angular stand alone test
(function() {
var existingAngular = window.angular;
require("angular");
var angular = window.angular;
window.angular = existingAngular || {};
module.exports = angular;
})();
@erickzanardo
erickzanardo / IgnoreSelfSignedCertificate.java
Created January 5, 2016 19:41
Java method to ignore self signed certificates
public static void trustSelfSignedCertificates() {
try {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
@erickzanardo
erickzanardo / gist:02d39aef78999ed5cc0c
Created January 11, 2016 16:05
Simple bash script to "deploy" some static project to github pages
#!/bin/bash
FOLDER=$1
REMOTE=$2
if [ "$2" = "" ]
then
REMOTE="origin"
fi
@erickzanardo
erickzanardo / pg_tablespace.sql
Created February 4, 2016 17:32
PG tablespace
# For many reason tablespace location should be on the partition root
sudo mkdir /root_of_fs/pgfoo
sudo chown postgres: /root_of_fs/pgfoo
CREATE TABLESPACE foo LOCATION '/root_of_fs/pgfoo';
ALTER DATABASE my_db TABLESPACE foo;
CREATE DATABASE my_db TABLESPACE foo;
@erickzanardo
erickzanardo / ControllerAdapter.lua
Last active February 18, 2016 00:00
Simple implementation of a Asteroids Like game mechanic
function ControllerAdapter(left, right, up, down)
local controller = {
l = left;
r = right;
u = up;
d = down
}
function controller:left()
return love.keyboard.isDown(self.l)
@erickzanardo
erickzanardo / sourceable.sh
Last active February 6, 2017 13:27
Simple script to easy add env variables, or changing the path without having to always change the bash[rc,_profile,etc] file. Add these lines to your bash[rc,_profile,etc] file once and then just add files to the folder configured on the SOURCEABLE_DIR variable.
# Sourceables
SOURCEABLE_DIR=/home/erick/sourceable/
DIRS=($(ls $SOURCEABLE_DIR))
for dir in "${DIRS[@]}"; do
if [[ "$dir" != *.ignore ]]
then
source "$SOURCEABLE_DIR$dir"
fi
done
@erickzanardo
erickzanardo / star-command.sh
Last active February 16, 2017 20:09
star-command
#!/bin/bash
function star-command {
if [ "$1" == "" ] || [ "$1" == "-h" ]; then
echo "star-command \"command to store on your favorites\""
echo "star-command -l \"list your favorites\""
elif [ "$1" == "-l" ]; then
cat ~/.star-commands
else
echo "$1" >> ~/.star-commands
@erickzanardo
erickzanardo / guide.md
Last active March 2, 2017 15:06
ReactNative via Wifi steps
  • Connect device via usb
  • Run adb tcpip 5555
  • Check the device by going on settings > wifi > ellipsis button on the top right corner > advanced
  • Run adb connect ###.###.#.##
  • (Optional) remove the usb cable
  • On the React Native app, shake the device to open the dev menu and go into Dev Settings
  • Click on Debug server host & port for device
  • Input the ip from your computer and the port 8081, like this ###.###.#.##:8081
  • Enjoy your development wihtout any cables :D
@erickzanardo
erickzanardo / PdfPoc.java
Created April 7, 2017 14:10
PDFBox and JFreeChart example
package br.com.tagview;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.jfree.chart.ChartFactory;
import React, {useState} from 'react';
import {
SafeAreaView,
StyleSheet,
View,
TouchableOpacity,
StatusBar,
Image,
} from 'react-native';