Skip to content

Instantly share code, notes, and snippets.

package portScan
object Run extends App {
(21 to 22).par.map { case port =>
try {
val socket = new java.net.Socket("192.168.1.1", port)
socket.close()
println(port)
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@firephil
firephil / JavaFXTrayIconSample.java
Created October 25, 2016 16:40 — forked from jewelsea/JavaFXTrayIconSample.java
Demonstrate using the System Tray (AWT) to control a JavaFX application.
import javafx.application.*;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.*;
import javax.imageio.ImageIO;
import java.io.IOException;
@firephil
firephil / AutoCompleteTextBox.java
Created February 26, 2018 23:19 — forked from floralvikings/AutoCompleteTextBox.java
Simple JavaFX TextBox with AutoComplete functionality based on a supplied set.
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Side;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
@firephil
firephil / BinarySearch.py
Created March 5, 2018 21:33
Simple Binary Search on a sorted list
def binarySearch(list, item):
first = 0
last = len(list) - 1
while first <= last:
i = (first + last) // 2
if list[i] == item:
return (item,i)
elif list[i] > item:
@firephil
firephil / BinarySearch.py
Created March 5, 2018 21:42
With Basic Error Handling Range Check
def binarySearch(list, item):
first = 0
last = len(list) - 1
if item < list[first] or item > list[last]:
return (item,-1)
while first <= last:
i = (first + last) // 2
@firephil
firephil / BinarySearch.py
Last active March 5, 2018 22:46
Binary Search with Iterative and Recursive implementation
def binarySearch(list, item):
first = 0
last = len(list) - 1
if item < list[first] or item > list[last]:
return (item,-1)
while first <= last:
i = (first + last) // 2
@firephil
firephil / BinarySeach_.idea_BinarySeach.iml
Created March 5, 2018 22:29
Binary Search added Recursive implementation
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.6 (BinarySeach)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@firephil
firephil / nqueen.scala
Created March 11, 2021 22:26 — forked from ornicar/nqueen.scala
solution to the n-queens problem based on "Programming in Scala"
// Solves the n-queens problem for an arbitrary board size
// Run for a board size of ten: scala nqueen.scala 10
object Nqueen {
type Queen = (Int, Int)
type Solutions = List[List[Queen]]
def main(args: Array[String]) {
val size: Int = args match {
case Array() => sys.error("Provide a board size")
case Array(n) => n.toInt
@firephil
firephil / NQueen.scala
Created March 11, 2021 22:31 — forked from pathikrit/NQueen.scala
O(n!) solution to the n-Queen puzzle (https://en.wikipedia.org/wiki/Eight_queens_puzzle)
/**
* Solves the n-Queen puzzle in O(n!)
* Let p[r] be the column of the queen on the rth row (must be exactly 1 queen per row)
* There also must be exactly 1 queen per column and hence p must be a permuation of (0 until n)
* There must be n distinct (col + diag) and n distinct (col - diag) for each queen (else bishop attacks)
* @return Vector p of length n such that p[i] is the column of the queen on the ith row in a solution
*/
def nQueens(n: Int) =
(0 until n)
.permutations