View hexadecimalcolorclock.html
<html> | |
<head> | |
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap" rel="stylesheet"> | |
<style> | |
#hexatime { | |
width: 300px; | |
text-align: center; | |
margin: 0 auto; | |
margin-top: 500px; |
View hexislight.js
function hexislight(color) { | |
var hex = color.replace('#', ''); | |
var red = parseInt(hex.substr(0, 2), 16); | |
var green = parseInt(hex.substr(2, 2), 16); | |
var blue = parseInt(hex.substr(4, 2), 16); | |
// it is a known formula, nothing magical here | |
var brightness = ((red * 299) + (green * 587) + (blue * 114)) / 1000; | |
return brightness > 155; | |
} |
View hexaTime.js
function hexaTime() { | |
var date = new Date(); | |
// we convert in the 0 .. 255 range | |
var seconds = parseInt(date.getSeconds() * 255 / 59); | |
var minutes = parseInt(date.getMinutes() * 255 / 59); | |
var hours = parseInt(date.getHours() * 255 / 23); | |
return "#" + toHex(hours) + toHex(minutes) + toHex(seconds); | |
} |
View ToHex.js
function toHex(d) { | |
var hex = ("0" + (Number(d).toString(16))).slice(-2).toUpperCase(); | |
return hex; | |
} |
View hexatime.html
<html> | |
<head> | |
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap" | |
rel="stylesheet"> | |
<style> | |
#hexatime { | |
width: 300px; | |
text-align: center; | |
margin: 0 auto; |
View MainActivity.java
package com.ssaurel.myanagram; | |
import android.app.Dialog; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.TextView; | |
import androidx.appcompat.app.AlertDialog; |
View LoadWords.java
private void loadWords() { | |
new Thread(() -> { | |
Anagram.loadWords(MainActivity.this); | |
runOnUiThread(() -> { | |
validate.setEnabled(Anagram.isLoaded()); | |
}); | |
}).start(); | |
} |
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:padding="16dp" | |
android:orientation="vertical" | |
tools:context=".MainActivity"> | |
<!-- We add a Dummy layout to prevent EditText to gain focus --> |
View Anagram.java
package com.ssaurel.myanagram; | |
import android.content.Context; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; |
View SameLetters.java
// Method for comparing two strings and returning true if they have same letters | |
public static boolean sameLetters(String a, String b) { | |
if (a == null) | |
return b == null; | |
if (b == null) | |
return false; | |
char[] left = a.toCharArray(); | |
char[] right = b.toCharArray(); |
NewerOlder