Skip to content

Instantly share code, notes, and snippets.

Tushar Sharma tush4r

View GitHub Profile
@tush4r
tush4r / Pcap4jLoop.java
Created Apr 11, 2017 — forked from kaitoy/Pcap4jLoop.java
Packet capture with Pcap4J in Java
View Pcap4jLoop.java
import java.io.IOException;
import org.pcap4j.core.BpfProgram.BpfCompileMode;
import org.pcap4j.core.NotOpenException;
import org.pcap4j.core.PacketListener;
import org.pcap4j.core.PcapHandle;
import org.pcap4j.core.PcapNativeException;
import org.pcap4j.core.PcapNetworkInterface;
import org.pcap4j.core.PcapNetworkInterface.PromiscuousMode;
import org.pcap4j.packet.Packet;
import org.pcap4j.util.NifSelector;
View TimeStampUtility.scala
import org.joda.time.format.DateTimeFormat
import org.joda.time.{DateTime, DateTimeZone}
import scala.util.Try
object TimeStampUtility {
def getCurrentTimeStamp(): Long = {
val timestamp: Long = System.currentTimeMillis / 1000
timestamp
@tush4r
tush4r / UITextFieldExtension.swift
Created Apr 8, 2016
Returns Int, Float, Double from TextField
View UITextFieldExtension.swift
extension UITextField {
var stringValue : String { return text ?? "" }
var integerValue: Int { return Int(stringValue) ?? 0 }
var doubleValue : Double { return Double(stringValue) ?? 0 }
var floatValue : Float { return Float(stringValue) ?? 0 }
}
let textField = UITextField()
textField.text.dynamicType // returns an Optional<String>.Type
let optionalIntegerValue = Int(textField.text!) // returns NIL
You can’t perform that action at this time.