Skip to content

Instantly share code, notes, and snippets.

View petehouston's full-sized avatar
in steroid mode at the moment ~

Pete Houston petehouston

in steroid mode at the moment ~
View GitHub Profile
((12, 18), 1/3)
((12, 19), 1/3)
((12, 80), 1/3)
((15, 12), 1/18)
((15, 18), 8/18)
((15, 19), 3/18)
((15, 80), 4/18)
((15, 88), 1/18)
((15, 91), 1/18)
@petehouston
petehouston / DownloadFile.java
Created January 7, 2019 16:01
Download file using Java
package com.kodemate.tutorials.downloadfile;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static org.hamcrest.core.Is.is;
@petehouston
petehouston / Article.java
Created April 6, 2018 09:50
Parse JSON in Java using Jackson
public class Article {
private String title;
private String author;
private String url;
private List<String> tags;
public Article() {
}
public Article(String title, String author, String url, List<String> tags) {
@petehouston
petehouston / Article.java
Created April 6, 2018 09:48
Parse JSON in Java using Gson
public class Article {
private String title;
private String author;
private String url;
private List<String> tags;
public Article() {
}
public Article(String title, String author, String url, List<String> tags) {
@petehouston
petehouston / response_xml_macro.php
Created November 25, 2016 09:19
Laravel response xml macro
Response::macro('xml', function(array $vars, $status = 200, array $header = [], $rootElement = 'response', $xml = null)
{
if (is_null($xml)) {
$xml = new SimpleXMLElement('<'.$rootElement.'/>');
}
foreach ($vars as $key => $value) {
if (is_array($value)) {
Response::xml($value, $status, $header, $rootElement, $xml->addChild($key));
} else {
@petehouston
petehouston / _README.md
Created November 12, 2016 18:20 — forked from teaualune/_README.md
An alternative routing example for React.js

This is a small example to build a simple routing solution for React.js instead of using the popular React Router.

It utilizes great libraries e.g. history and universal-router which are React-independent.

The example includes:

  • A singleton history object for URL navigation
  • A Router component to route different child components
  • A Link component that acts as those in React Router or in React Static Boilerplate
  • An example component App to demostrate their usages
@petehouston
petehouston / gist:00e1892f1449340d61e9e10f960543a3
Created November 6, 2016 14:25 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@petehouston
petehouston / xor_encrypt.c
Created March 23, 2016 13:28
XOR encrypt
/**
* $ gcc -o program xor_encrypt.c
* $ ./program
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LOG printf
@petehouston
petehouston / mail.php
Created May 15, 2015 07:39
Passing data to queue in Laravel
public function sendUserRegistered($user)
{
$view = 'user_registered';
$data = [
'email' => $user->email,
'name' => $user->name,
'token' => $user->verification->token
];