Skip to content

Instantly share code, notes, and snippets.

View drem-darios's full-sized avatar

Drēm Darios drem-darios

View GitHub Profile
@drem-darios
drem-darios / LinkedList.java
Created January 8, 2020 05:11
Simple Doubly Linked List Implementation
public class LinkedList {
private Node head;
private Node tail;
public LinkedList() {
}
private class Node {
@drem-darios
drem-darios / UserInput.java
Created January 7, 2020 07:50
User interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.
import java.lang.StringBuilder;
public class UserInput {
public static class TextInput{
StringBuilder input = new StringBuilder();
public void add(char c) {
input.append(c);
}
@drem-darios
drem-darios / SortedSearch.java
Last active January 7, 2020 07:50
Counts the number of array elements that are less than the parameter lessThan
import java.util.*;
public class SortedSearch {
public static int countNumbers(int[] sortedArray, int lessThan) {
int left = 0;
int right = sortedArray.length - 1;
int count = 0;
while (left <= right)
{
@drem-darios
drem-darios / node.service
Created September 15, 2018 22:09
This starts a node service located in the /app directory using systemd. Put this file in /etc/systemd/system
[Unit]
Description=Node server
Documentation=https://google.com
After=network.target
[Service]
Environment=HOST=0.0.0.0
Environment=PORT=3000
Type=simple
User=ubuntu
@drem-darios
drem-darios / new-service
Last active September 15, 2018 22:10
This is a template for creating a new service on a linux box using init.d. Place this file in /etc/init.d Reference: https://unix.stackexchange.com/questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot
#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....
### BEGIN INIT INFO
### END INIT INFO
# Source function library.
#. /etc/init.d/functions
start() {
# code to start app comes here
@drem-darios
drem-darios / ethereum-startup.sh
Created November 27, 2017 18:08
Bash script to install Ethereum on a Mac OS machine
# Install Go-Ethereum (geth)
brew tap ethereum/ethereum
brew install ethereum
# Install node modules to support Ethereum front end
npm install ethereumjs-testrpc [email protected]
npm install solc
npm install -g truffle
npm install -g webpack
# Run an in-memory test Ethereum blockchain
@drem-darios
drem-darios / salt_signature.py
Created March 9, 2017 18:06
Python example of how to create a salt and use a secret key to generate a signature using the salt
import hmac
import os
import hashlib
import base64
import unittest
__author__ = 'drem'
class SecurityUtil(object):
@drem-darios
drem-darios / SaltSignatureGenerator.java
Created March 9, 2017 18:04
Salt and Signature Java example. This is an example of how someone can do simple one way encryption so they don't have to store passwords in plaintext files. This is still vulnerable in other ways(such as dictionary attacks) but it better than nothing. To test this code, run 'mvn clean install' then run 'java -cp target/salt-signature-security-j…
package com.drem.security.util;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.Properties;
import java.util.Random;
@drem-darios
drem-darios / BestTrade.java
Created March 3, 2017 02:25
Figures out the best trade in a few days
import java.io.*;
import java.util.*;
/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.
*/
import java.io.*;
import java.util.*;
/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.
*/