This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; round-half-up: number -> integer | |
;; | |
;; Rounds the number to the nearest neighbor | |
;; | |
;; Example: (round-half-up 2.5) = 3 | |
(define (round-half-up number) (floor (+ number .5))) | |
;; Tests | |
(check-expect (round-half-up 2.5) 3) | |
(check-expect (round-half-up 3) 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<settings> | |
<!-- localRepository | |
| The path to the local repository maven will use to store artifacts. | |
| | |
| Default: ~/.m2/repository | |
--> | |
<localRepository>/path/to/local/repo</localRepository> | |
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.games647.JarUtils; | |
import com.sun.tools.attach.VirtualMachine; | |
import java.lang.management.ManagementFactory; | |
public class AgentLoadingRuntime { | |
public static void loadAgent(String[] args) { | |
String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); | |
int p = nameOfRunningVM.indexOf('@'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.lang.management.ManagementFactory; | |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import javax.management.InstanceNotFoundException; | |
import javax.management.MBeanException; | |
import javax.management.MBeanServer; | |
import javax.management.MalformedObjectNameException; | |
import javax.management.ObjectName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.lang.management.ManagementFactory; | |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import javax.management.InstanceNotFoundException; | |
import javax.management.MBeanException; | |
import javax.management.MBeanServer; | |
import javax.management.MalformedObjectNameException; | |
import javax.management.ObjectName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
public class JavaHasher { | |
private static final String HASH_ALGO = "SHA512"; | |
public String hashInput(String input) { | |
String hashed = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example output: | |
SI BINARY | |
0: 0 B 0 B | |
27: 27 B 27 B | |
999: 999 B 999 B | |
1000: 1.0 kB 1000 B | |
1023: 1.0 kB 1023 B | |
1024: 1.0 kB 1.0 KiB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mindrot.jbcrypt.BCrypt; | |
public class BCryptHasher { | |
public static String hashPassword(String rawPassword) { | |
//generate a different salt for each user | |
return BCrypt.hashpw(rawPassword, BCrypt.gensalt()); | |
} | |
public static boolean checkPassword(String passwordHash, String userInput) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import org.hyperic.sigar.CpuInfo; | |
import org.hyperic.sigar.CpuPerc; | |
import org.hyperic.sigar.FileSystemUsage; | |
import org.hyperic.sigar.Mem; | |
import org.hyperic.sigar.NetInterfaceStat; | |
import org.hyperic.sigar.Sigar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.sql.Timestamp; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.List; |