Posts

Mongoose: how to define a combination of fields to be unique? -

if had schema this: var person = new schema({ firstname: string, lastname: string, }); i'd ensure there 1 document same firstname , lastname. how can accomplish this? you can define unique compound index using index call on schema: person.index({ firstname: 1, lastname: 1}, { unique: true });

windows - How to real time convert Ethernet packet to Wireless packet? -

in case of ethernet header have destination mac address , source mac address. in case of 802.11 packets there @ minimum 3 mac addresses , in cases 4 mac addresses. how 802.11 packet formed using 802.3 packet? know native wifi doing conversion in case windows. want know how achieving? "how 802.11 packet formed using 802.3 packet?" the conversion (between 802.3 , 802.11 mac frames) happens @ link layer. implementation details platform , driver-dependent. an example of how these done in linux kernel (using soft-mac 802.11 driver): http://lxr.free-electrons.com/source/net/wireless/util.c#l412 http://lxr.free-electrons.com/source/net/wireless/util.c#l530

xml - Haxe Iteration of defining variables -

i have chunk of code parsing xml variables. on 1 of variables, there never more 12 there may less. trying define each of these variables multiple times second. need them defined if have variable because right now, if there less 12 variables, program crashes. right code below works, if there 12 values present in xml document. how itterate code don't have list of "if != null" statements? var _vol1 = (ipts[0].volume); var _vol2 = (ipts[1].volume); .... .... var _vol12 = (ipts[11].volume); this code works when 12 values in xml document crashes if there less 12 might case. how structure code define/redefine variable if there value , not null? what needs iterated???? if ((ipts[0].volume) != null ){ var _vol1 = (ipts[0].volume); } i researched on haxe website wasnt sure applicable. syntax , programming not greatest. help. sorry if bad question. update: here complete code of now. doesn't crash not defining volume variables anymore added if statements var...

sql - Return values based matching times and days -

i'm attempting match results of employees schedules vs reporting schedules. need output report shows reports , assigned them. place i'm having trouble based on day of week. my reportschedule table looks this: ╔══════════════╦══════════════╦══════╦══════╦══════╦══════╦══════╦══════╦════╗ ║ reportid ║ time ║ m ║ tu ║ w ║ th ║ f ║ sa ║ su ║ ╠══════════════╬══════════════╬══════╬══════╬══════╬══════╬══════╬══════╬════╣ ║ 1001 ║ 06:18:00 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 0 ║ 0 ║ ║ 1002 ║ 06:48:00 ║ 0 ║ 0 ║ 0 ║ 0 ║ 0 ║ 1 ║ 1 ║ ║ 1003 ║ 07:18:00 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ ╚══════════════╩══════════════╩══════╩══════╩══════╩══════╩══════╩══════╩════╝ my employeesschedule table looks this: ╔════════════╦══════════╦═════════════╦═══════════╦═══╦════╦═══╦════╦═══╦════╦════╗ ║ employeeid ║ reportid ║ reportstart ║ reportend ║ m ║ tu ║ w ║ th ║ f ║ sa ║ su ║ ╠════════...

android - Robolectric: failed on start test cause of wifi start scan -

i've created little test under robolectric. unfortunately, must comment these lines having success test : public class myapplication extends application { private void setupapplication() { .... //mnetworkevents = new networkevents(this, eventbus.getdefault()) // .withpingurl(buildconfig.ping_server_url) // .withpingtimeout(buildconfig.ping_timeout); } this class "networkevents" allows test internet connectivity. , in class there call: public static void startwifiscan(context context) { wifimanager wifimanager = (wifimanager) context.getsystemservice(context.wifi_service); wifimanager.startscan(); } and problem start wifi scan... this error: java.lang.nullpointerexception @ android.net.wifi.wifimanager.startscan(wifimanager.java:995) how can run test without comment these line in application class ?? thanks guys! i've tried reproduce error , found same. thinking should first set wifimanager start...

Java 8 : Invoke Interface's static method using reflection -

i want invoke static method of java 8 interface using reflection api. public interface timeclient { static void teststatic() { system.out.println("in static"); } } i able invoke default method of interface unable invoke static method. i see no problems: timeclient.class.getdeclaredmethod("teststatic").invoke(null); works without problems , prints "in static". getmethod works expected: timeclient.class.getmethod("teststatic").invoke(null);

xcode - Unable to install iOS Simulator 8.4 -

Image
i have xcode version 6.4 (6e35b), os x v 10.10.4 , ios simulator not show in preferences: if click "check , install now" nothing happens. have machine next me , installed correctly. ideas how fix it? xcode 6.4 comes ios 8.4 simulator runtime. a default set of devices should created automatically. if deleted them, can recreate them xcode's devices window or command line using xcrun simctl create ...