Skip to content

Instantly share code, notes, and snippets.

View pethaniakshay's full-sized avatar
🎯
Focusing

Akshay Pethani pethaniakshay

🎯
Focusing
View GitHub Profile
@vasanthk
vasanthk / System Design.md
Last active May 31, 2024 01:39
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
/*
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()()"
*/
public class Solution {
@mugli
mugli / install-java7.sh
Created January 30, 2014 21:51
Silently install Oracle Java 7 on Ubuntu (without license agreement step)
#!/bin/bash
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
# Enable silent install
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
@jewelsea
jewelsea / LoginController.java
Created January 25, 2013 02:47
JavaFX sample for an fxml based Login screen to main application transition with login session data transfer
package login;
import javafx.event.*;
import javafx.fxml.FXML;
import javafx.scene.control.*;
/** Controls the login screen */
public class LoginController {
@FXML private TextField user;
@FXML private TextField password;
@avilches
avilches / Sha.java
Created December 21, 2010 16:25
How to encode a hex SHA256 in Java
import java.security.*;
public class Sha {
public static String hash256(String data) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(data.getBytes());
return bytesToHex(md.digest());
}
public static String bytesToHex(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));