Skip to content

Instantly share code, notes, and snippets.

import java.util.Random; // for test code
final class BFS {
/* finds nearest ant to a destination in a maze.
You give it a (partial) map and it plots a route using naive BFS.
As you discover more obstacles you can call addWater() for them.
It makes extensive use of pre-allocated data for intermediate results,
so you must extract the path for each call to findNearestAnt() or you
lose it. */
@snzip
snzip / SQLite-PHP-quickstart.php
Created May 5, 2018 05:34 — forked from bladeSk/SQLite-PHP-quickstart.php
SQLite3 PHP Quickstart Tutorial
<?php
// This file walks you through the most common features of PHP's SQLite3 API.
// The code is runnable in its entirety and results in an `analytics.sqlite` file.
// Create a new database, if the file doesn't exist and open it for reading/writing.
// The extension of the file is arbitrary.
$db = new SQLite3('analytics.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
@snzip
snzip / install-java-8-on-ubuntu-14.04-auto-accept-licence-agreement.sh Install oracle Java 8 on Ubuntu 14.04 and automatically accept the licence agreement. 100% hands-free install.
#! /bin/bash
sudo apt-get update
sudo apt-get install -y software-properties-common debconf-utils
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer
#sudo update-alternatives --config java;
sudo apt-get install -y oracle-java8-set-default
@snzip
snzip / oracle_java8.sh
Created April 19, 2018 02:58 — forked from amatellanes/oracle_java8.sh
Install Oracle Java 8 on Ubuntu 14.04 LTS (Trusty Tahr)
sudo add-apt-repository ppa:webupd8team/java;
sudo apt-get update;
sudo apt-get install oracle-java8-installer;
sudo update-alternatives --config java;
java -version;
@snzip
snzip / docker-compose-drupal-postgres.yml
Last active April 14, 2020 13:54 — forked from stevewithington/docker-compose-drupal-postgres.yml
Drupal with Postgres Docker Compose File
version: '3.1'
# Note: use the database service name `db` in the Host IP Address field ...
# Or, `docker container inspect {postgrescontainerid}` to obtain the IP Address needed for completing the Drupal setup screen.
services:
# Postgres
db:
image: postgres:11.7
restart: always
@snzip
snzip / kThreads.sh
Created April 10, 2018 12:51
Get lock java thread
#!/bin/bash
# author: michael
mkdir -p ./threads
cd ./threads
#get commands
jps -l > command.lst
jps |cut -d ' ' -f 1 >pids.tmp
@snzip
snzip / get_image_info.py
Created January 16, 2018 06:22 — forked from cgoldberg/get_image_info.py
validate and analyze dimensions of [PNG, JPG, GIF], image files in Python.
#!/usr/bin/env python
#
# Corey Goldberg, 2013
#
# Python 2.7
"""validate and analyze dimensions of image files. Supports: PNG, JPG, GIF."""
@snzip
snzip / gist:16f6eb86c74d74e360c76f4d4de35edc
Created December 22, 2017 15:36 — forked from liudong/gist:3993726
Java: Generate Public/Private Keys
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.KeyFactory;
import java.security.spec.EncodedKeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.NoSuchAlgorithmException;
@snzip
snzip / setproxy
Created December 20, 2017 11:54 — forked from beradrian/setproxy
Set proxy for npm and git
# set a proxy
set HTTP_PROXY=
set HTTPS_PROXY=%HTTP_PROXY%
npm config set proxy %HTTP_PROXY%
npm config set https.proxy %HTTPS_PROXY%
npm config set https-proxy %HTTPS_PROXY%
git config --global http.proxy %HTTP_PROXY%
git config --global https.proxy %HTTPS_PROXY%
# unset proxy
@snzip
snzip / install_elixir.md
Created December 3, 2017 14:01 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.